Parameterized URL in a web service problem

L

Luis Arvayo

Hi,

My app is a general purposes app and not a specific one.

This means that customer who bought the application can have a web service
placed on the server on any given URL.

I use the wsdl tool to create the service class, but the reference to the
url is hard coded inside the class.

What is the correct way to implement the web service with a parameterized
URL address in such a way that end user of the app can define it?



Example of my class where you can see the hard coded url:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="SolverServiceSoap",
Namespace="http://localhost/SolverService/")]
public class SolverService :
System.Web.Services.Protocols.SoapHttpClientProtocol {
/// <remarks/>
public SolverService() {
this.Url = http://localhost/SolverService/SolverService.asmx;
}

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/SolverService/Close,
RequestNamespace="http://localhost/SolverService/",
ResponseNamespace="http://localhost/SolverService/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void Close() {
this.Invoke("Close", new object[0]);
}

.....


Thanks in advance.
 
Y

Yunus Emre ALPÖZEN [MCSD.NET]

If web service description remains same u can set web service url at run
time.. Here is a pseudo code example:

SolverService sService = new SolverService ();
// and set sService.Url to URL what ever u want..

But be sure wsdl is same..
--
HTH

Thanks,
Yunus Emre ALPÖZEN
BSc, MCSD.NET
 
L

Luis Arvayo

Thanks for answering.

The problem here is that the methods of the web service class also maintains
a reference to the url, like in this web method:



/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/MapSolverService/Close",
RequestNamespace="http://localhost/MapSolverService/",
ResponseNamespace="http://localhost/MapSolverService/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void Close() {
this.Invoke("Close", new object[0]);
}




So, how to change that ?

Thanks






Yunus Emre ALPÖZEN said:
If web service description remains same u can set web service url at run
time.. Here is a pseudo code example:

SolverService sService = new SolverService ();
// and set sService.Url to URL what ever u want..

But be sure wsdl is same..
--
HTH

Thanks,
Yunus Emre ALPÖZEN
BSc, MCSD.NET

Luis Arvayo said:
Hi,

My app is a general purposes app and not a specific one.

This means that customer who bought the application can have a web
service placed on the server on any given URL.

I use the wsdl tool to create the service class, but the reference to the
url is hard coded inside the class.

What is the correct way to implement the web service with a parameterized
URL address in such a way that end user of the app can define it?



Example of my class where you can see the hard coded url:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="SolverServiceSoap",
Namespace="http://localhost/SolverService/")]
public class SolverService :
System.Web.Services.Protocols.SoapHttpClientProtocol {
/// <remarks/>
public SolverService() {
this.Url = http://localhost/SolverService/SolverService.asmx;
}

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/SolverService/Close,
RequestNamespace="http://localhost/SolverService/",
ResponseNamespace="http://localhost/SolverService/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void Close() {
this.Invoke("Close", new object[0]);
}

....


Thanks in advance.
 
Y

Yunus Emre ALPÖZEN [MCSD.NET]

Hi again,
U can change web service reference from static to dynamic.. Request and
Response Namespace are not required to be "localhost".. Just give a generic
name like "tempuri.org"... Change them and call your web service, and see
what is going on...

Using VS.NET, u can add a web reference.. But it is not an obligation. You
can simply implement Web Service Proxy class. If u are using primitive data
types, u can easily call it. Otherwise u must share your custom objects with
callee applications. Also, u can mark your input and output parameters as
XML serializable. Thus, would help u to call ws from different platforms..

--
HTH

Thanks,
Yunus Emre ALPÖZEN
BSc, MCSD.NET

Luis Arvayo said:
Thanks for answering.

The problem here is that the methods of the web service class also
maintains a reference to the url, like in this web method:



/// <remarks/>

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/MapSolverService/Close",
RequestNamespace="http://localhost/MapSolverService/",
ResponseNamespace="http://localhost/MapSolverService/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void Close() {
this.Invoke("Close", new object[0]);
}




So, how to change that ?

Thanks






Yunus Emre ALPÖZEN said:
If web service description remains same u can set web service url at run
time.. Here is a pseudo code example:

SolverService sService = new SolverService ();
// and set sService.Url to URL what ever u want..

But be sure wsdl is same..
--
HTH

Thanks,
Yunus Emre ALPÖZEN
BSc, MCSD.NET

Luis Arvayo said:
Hi,

My app is a general purposes app and not a specific one.

This means that customer who bought the application can have a web
service placed on the server on any given URL.

I use the wsdl tool to create the service class, but the reference to
the url is hard coded inside the class.

What is the correct way to implement the web service with a
parameterized URL address in such a way that end user of the app can
define it?



Example of my class where you can see the hard coded url:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="SolverServiceSoap",
Namespace="http://localhost/SolverService/")]
public class SolverService :
System.Web.Services.Protocols.SoapHttpClientProtocol {
/// <remarks/>
public SolverService() {
this.Url = http://localhost/SolverService/SolverService.asmx;
}

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/SolverService/Close,
RequestNamespace="http://localhost/SolverService/",
ResponseNamespace="http://localhost/SolverService/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void Close() {
this.Invoke("Close", new object[0]);
}

....


Thanks in advance.
 
D

DC

By the way, this statement:

indicates a misunderstanding of XML namespaces. Those strings you referred
to in the generated proxy class:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/MapSolverService/Close",
RequestNamespace="http://localhost/MapSolverService/",
ResponseNamespace="http://localhost/MapSolverService/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void Close() {
this.Invoke("Close", new object[0]);
}

Those strings beginning with http:// are not URLs associated to the
webservice. they are URIs used for namespaces in the XML that is handed
back and forth. they are URIs not URLs. And they are independent of the
endpoint. They could just as easily be
urn:this-is-my-request-namespace
and
urn:this-is-my-response-namespace-ha-ha-ha-ha-aint-it-grand

-D

--
-Dino
D i n o . C h i e s a AT M i c r o s o f t . c o m




Yunus Emre ALPÖZEN said:
Hi again,
U can change web service reference from static to dynamic.. Request and
Response Namespace are not required to be "localhost".. Just give a
generic name like "tempuri.org"... Change them and call your web service,
and see what is going on...

Using VS.NET, u can add a web reference.. But it is not an obligation. You
can simply implement Web Service Proxy class. If u are using primitive
data types, u can easily call it. Otherwise u must share your custom
objects with callee applications. Also, u can mark your input and output
parameters as XML serializable. Thus, would help u to call ws from
different platforms..

--
HTH

Thanks,
Yunus Emre ALPÖZEN
BSc, MCSD.NET

Luis Arvayo said:
Thanks for answering.

The problem here is that the methods of the web service class also
maintains a reference to the url, like in this web method:



/// <remarks/>

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/MapSolverService/Close",
RequestNamespace="http://localhost/MapSolverService/",
ResponseNamespace="http://localhost/MapSolverService/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void Close() {
this.Invoke("Close", new object[0]);
}




So, how to change that ?

Thanks






Yunus Emre ALPÖZEN said:
If web service description remains same u can set web service url at run
time.. Here is a pseudo code example:

SolverService sService = new SolverService ();
// and set sService.Url to URL what ever u want..

But be sure wsdl is same..
--
HTH

Thanks,
Yunus Emre ALPÖZEN
BSc, MCSD.NET

Hi,

My app is a general purposes app and not a specific one.

This means that customer who bought the application can have a web
service placed on the server on any given URL.

I use the wsdl tool to create the service class, but the reference to
the url is hard coded inside the class.

What is the correct way to implement the web service with a
parameterized URL address in such a way that end user of the app can
define it?



Example of my class where you can see the hard coded url:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="SolverServiceSoap",
Namespace="http://localhost/SolverService/")]
public class SolverService :
System.Web.Services.Protocols.SoapHttpClientProtocol {
/// <remarks/>
public SolverService() {
this.Url = http://localhost/SolverService/SolverService.asmx;
}

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/SolverService/Close,
RequestNamespace="http://localhost/SolverService/",
ResponseNamespace="http://localhost/SolverService/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void Close() {
this.Invoke("Close", new object[0]);
}

....


Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top