Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
West Wind WebSurge - Rest Client and Http Load Testing for Windows

Invalid Service Urls in a WSDL Definition


:P
On this page:

I'm working on a Web Service project project for a customer with published WSDL from a third part provider. The WSDL has a service address embedded at the bottom with some nonesense URL like this:

<soap:address location="To Be Determined Later" />

When you import this WSDL into .NET either with WCF or a standard Web Reference it looks OK and the code compiles.

However at runtime you'll find that even if you run code like this where you set your own service reference:

Service = new OmnicellMessageService();    // failure here at service proxy instantiation
Service.Url = App.Configuration.ServiceUrl;

that the service instantiation actually fails. IOW, it fails before the service call is made and before you even get a chance to assign a custom URL.The error is invalid url specified.

What's happening is that the service URL is assigned somewhere in the construction code and apparently it uses the Uri class. If an invalid URI is provided URI gets set to null or bombs outright and that's how this failure occurs.

Moral of the story: Make sure you use a valid service uri even if it is a completely obvious bogus.

So I turned the above into:

<soap:address location=http://ToBeDeterminedLater.net/ />

Which makes the call work as long as the service address is dynamically set later. Seems obvious now, but not so obvious as I was trying to find the problem's cause <g>.

Posted in Web Services  


West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024