2

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.

Community
  • 1
  • 1
capdragon
  • 14,565
  • 24
  • 107
  • 153

3 Answers3

2

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.

Mark Avenius
  • 13,679
  • 6
  • 42
  • 50
  • @capdragon: it looks like the address in incorrect for the service. The error I get back is "The root element of a W3C XML Schema should be ..." which means the address you provided is trying to execute a request, not expose the methods made available by the service. Are you hosting this service? – Mark Avenius Feb 10 '11 at 19:46
  • that's correct, i get the same error. I am not hosting this service. I'm thinking it does not have the WSDL associated with it. – capdragon Feb 10 '11 at 19:47
  • @capdragon: exactly. Do you have a contact at the hosting company that can point you toward the wsdl? That is indeed what you need. – Mark Avenius Feb 10 '11 at 19:53
2

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

Basic
  • 26,321
  • 24
  • 115
  • 201
  • @capdragon, no I didn't - as you didn't specify that trying that gave an error. Mark is leading you to the correct answer so I won't duplicate his answers. If you could provide as much information as possible in your question next time, you're more likely to get useful answers – Basic Feb 10 '11 at 19:56
  • @Basiclife: You're right, i should have mentioned i was getting an error. Please keep checking back in case we are not able to solve it, you might have some ideas. I also have and Edit that provides more info. – capdragon Feb 10 '11 at 20:12
  • @Basiclife: When i added the reference it did not modify my webconfig. – capdragon Feb 10 '11 at 20:26
  • Are you adding the reference directly to your website or to another project within the solution? It's also possible the change had been made by a previous attempt. I'll add a sample xml block to my post in 2 secs... – Basic Feb 10 '11 at 20:31
  • Or maybe I won't... I also get the same as you (no .config change). This is a little unexpected as I haven't seen this behavior before. Perhaps because I'm used to WCF/SOAP services. Let me investigate and I'll get back to you. – Basic Feb 10 '11 at 20:36
  • @Capdragon - I can't seem to get either a change to the config file or (more importantly) a proxy class generated using that URL. (Specifically, it downloads the WSDL and associated files but doesn't create any classes I can reference). I'm not sure what you rproblem i - I'll keep trying but can't guarantee I'll have an answer quickly... – Basic Feb 10 '11 at 20:46
1

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.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • @cap: you didn't say you were using an ASP.NET Web Site!!! If you're going to use those, then you **MUST** inform people who are trying to help you. Web Site "Projects" are totally unlike anything else in .NET or Visual Studio, so our assumptions will _always_ be wrong unless you tell us. – John Saunders Feb 10 '11 at 20:33
  • @cap: you're using a web site. Your code is compiled on the fly, possibly even generated on the fly. I have no idea how you should find out which is the proxy class. It probably has the same name as the name of the service, and it's probably not in any namespace because web sites think you're too stupid to understand namespaces. – John Saunders Feb 10 '11 at 20:34
  • @John: Sorry i probably should have tagged asp.net instead of .net. I did not know the web site projects were so different than anything else in .NET. – capdragon Feb 10 '11 at 20:36
  • @cap: it's not ASP.NET. ASP.NET Web Application Projects are normal projects. It's only the web sites, which don't even have project files. – John Saunders Feb 10 '11 at 20:37
  • @John: So i should be going about his differently then. creating a .NET proxy service for the external web service perhaps? – capdragon Feb 10 '11 at 20:38
  • @John: So if i create a "file based" instead of IIS based website? – capdragon Feb 10 '11 at 20:39
  • @John: I tried adding the reference to a Class Library project and it creates the Reference.cs file but it's empty! – capdragon Feb 10 '11 at 20:52
  • @cap: look in the output window to see if there are any errors. If that doesn't help, then try it at the command line using the svcutil.exe program. Also, it has nothing to do with file-based vs. IIS-based. It's ASP.NET Web Site projects that are unique. I recommend you use Web Application Projects in the future. – John Saunders Feb 11 '11 at 02:27
  • @John: Thanks for your help. Please see my edit #3. Being an MVP and all, do you think my problems have been the schemas (not being .NET friendly, java people say they have no problem), or .NET's ability to deal with such large schemas? – capdragon Feb 11 '11 at 14:43
  • @cap: The problem will have nothing to do with the size or complexity of the schemas. I bet it will have to do with assumptions made by the schema authors. One common assumption is that the WSDL processor will follow `xsi:schemaLocation` attributes to find the schemas. svcutil won't do that for security reasons. Try it from the command line and specify the URL for all WSDL and ALL schema files. If you tell it to go there, it will go there and get the schema. It's just not willing to believe the schema isn't sending you to some spam site. – John Saunders Feb 11 '11 at 17:08
  • @John: Do you happen to know any blog, article, or document that talk about many of these nuances between Inter operable XSDs for Java and .NET? – capdragon Feb 11 '11 at 19:45
  • @cap: it's not an interop issue at all. The tool simply won't follow links that might lead who knows where just because they happen to be in the schema file. Instead, you have to tell it explicitly which schemas to use. – John Saunders Feb 11 '11 at 20:15
  • @John: which leads me to my next question: http://stackoverflow.com/questions/4974146/how-to-determine-what-schema-files-xsd-to-include-on-my-svcutil-command-line – capdragon Feb 11 '11 at 21:17