How do i 'add web/service reference' to the following web service?

8.7k views Asked by At

Given the following url web service:

http://geoss.compusult.net/wes/serviceManagerCSW/csw?request=GetCapabilities&service=CSW

How would i create the proxy classes for the service?

More information HERE.

EDIT #1:

The hosting service above is implementing an OGC standard (CSW). The schemas for this standard are hosted HERE. And they have some WSDLs HERE. If i was to place the URL to one of those WSDL into visual studio's "add reference/service" i get a list of web operations and will generate a reference. However, that will not work because it does not know about the true hosting provider. So i'm not quite sure what to do.

Edit #2:

This is what it generated: enter image description here

EDIT #3:

Following John Saunders's comment to check for erors, i got the following:

Custom tool error: Failed to generate code for the service reference 'ServiceReference1'. Please check other error and warning messages for details. D:\temp\WebApplication2\WebApplication2\Service References\ServiceReference1\Reference.svcmap 1 1 WebApplication2

So i checked the warnings and i saw a few warnings similar to this:

Warning 1 Custom tool warning: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter Error: Schema with target namespace 'http://www.opengis.net/cat/csw/2.0.2' could not be found. XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.opengis.net/cat/csw/2.0.2/requests']/wsdl:portType[@name='csw'] D:\temp\WebApplication2\WebApplication2\Service References\ServiceReference1\Reference.svcmap 1 1 WebApplication2

And these are the same types of warnings i've been getting when doing anything with with these schemas in .NET. Aren't schemas supposed to work with any language? Here are some example of my heart ache with .NET and these schemas: HERE HERE HERE

So i'm not sure whether to blame the schemas or .NET for not being able to deal with such large schemas.

Event though Marc and Basiclife both provided answers that would have normally worked on "normal" schemas, John is getting the answer because he helped me troubleshoot it when i did not think it was a troubleshooting issue, but rather something i was missing. I should have known with these schemas though i thought creating the client wouldn't be as much of a big deal.

3

There are 3 answers

13
John Saunders On BEST ANSWER

Use the actual WSDLs to generate the service reference. Then, when you open the proxy class, use the constructor overload that includes an EndpointAddress. That will include the URL of the actual service.

The URL in the WSDL is only a hint.

3
Mark Avenius On

Right-click on your project, and go to Add Service Reference. Click Advanced at the bottom-left, then Add Web Reference at the bottom left again.

When you put in the URL, it will look up the available services, which you can select and give a name for within your project.

Edit:

Once you have the wsdl imported, you can change its base address via your app config.

Edit 2:

I am also used to WCF services :-) To change the URL, right-click on your reference, go to Properties, and change the Web Reference URL to whatever you need.

Edit 3:

When I add the reference, the following warning message appears in my Error List:

Warning 1 Custom tool warning: DiscoCodeGenerator unable to initialize code generator. No code generated. s:\dev\Sandbox\Sandbox\Web References\net.opengis.schemas\Reference.map

This is why Reference.cs is empty.

6
Basic On

Right-click the project, select Add Service Reference. Enter the URL provided...

EDIT: Add the reference to the WSDL. This is what VS needs to create the proxies.

Once the proxies have been created, you can edit the URL it actually uses to access the service in the web.config / app.config file for your application