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

capdragon picture capdragon · Feb 10, 2011 · Viewed 8.1k times · Source

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.

Answer

Mark Avenius picture Mark Avenius · Feb 10, 2011

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.