开发者

troubles with generating a service reference

开发者 https://www.devze.com 2023-02-21 04:03 出处:网络
I have to build a .Net application that consumes a bunch of web service. This web service runs under weblogic. The WSDL of the web services mention a XSD file that describes the types.

I have to build a .Net application that consumes a bunch of web service. This web service runs under weblogic. The WSDL of the web services mention a XSD file that describes the types.

When I try to add a "Se开发者_如何学Crvice reference" with VS studio, I have some errors :

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://mycustomer/ws/types' could not be found. XPath to Error Source: //wsdl:definitions[@targetNamespace='http://mycustomer/ws/wsdl']/wsdl:portType[@name='lbWebPT'] C:\Projects\mycustomerproject\Service References\ClientService\Reference.svcmap

X3 for the portType, Binding and port elements of the wsdl file.

I was guessing this was because of the missing types defined in the xsd file. To workaround this error, and also to avoid duplicate code, I run the following command on my xsd file (in a pre-build event command line) :

"%ProgramFiles%\Microsoft SDKs\Windows\v7.0A\bin\xsd.exe" "$(ProjectDir)xsdofmycustomer.xsd" /namespace:"MyCustomer.WebServices.Types" /c /o:"$(ProjectDir)."

this command successfully produces a code file with the types and with the correct namespace defined in the XmlRootAttribute.

this code has been put a dedicated VS project. The project where I'm trying to reference the service reference this project. However, the error is still occurring.

What can I do to solve my problem ?

PS: I was able to partially solve my problem using svcutil.exe pathtowsdl pathtoxsd, but I'd like to be able to maintain the reference in VS for ease of use.

thx


I'm not a fan of using project Service References because of the cruft the proxy generator inserts by default. But, if you really want to use Service References for your project then you need to merge the contents of the wsdl & xsd files into a single file. The Service Reference UI assumes all the data it needs to generate the proxy is in the file you give it. SvcUtil is more flexible as you found out. You should able to replace the wsdl:import element with a wsdl:types element that contains the xsd file contents (without the xml directive of course). Next, you enter the path to the file in the address textbox of the Add Service Reference dialog and you should be good to go with Visual Studio catered proxy goodness.

0

精彩评论

暂无评论...
验证码 换一张
取 消