Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / December 2005

Tip: Looking for answers? Try searching our database.

Parameterized URL in a web service problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Luis Arvayo - 29 Nov 2005 19:08 GMT
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.
Yunus Emre ALPÖZEN [MCSD.NET] - 29 Nov 2005 19:42 GMT
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..
Signature

HTH

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

> Hi,
>
[quoted text clipped - 35 lines]
>
> Thanks in advance.
Luis Arvayo - 29 Nov 2005 21:14 GMT
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

> If web service description remains same u can set web service url at run
> time.. Here is a pseudo code example:
[quoted text clipped - 42 lines]
>>
>> Thanks in advance.
Yunus Emre ALPÖZEN [MCSD.NET] - 30 Nov 2005 19:17 GMT
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..

Signature

HTH

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

> Thanks for answering.
>
[quoted text clipped - 63 lines]
>>>
>>> Thanks in advance.
DC - 01 Dec 2005 02:56 GMT
By the way, this statement:

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

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/",
[quoted text clipped - 4 lines]
>>            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

Signature

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

> Hi again,
> U can change web service reference from static to dynamic.. Request and
[quoted text clipped - 76 lines]
>>>>
>>>> Thanks in advance.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.