简体   繁体   中英

How to set up a schema to use for generating proxy classes

I'm consuming a WSDL and in this WSDL there're some methods and types defined.

Here's an example of the XML in the WSDL:

<operation name="GETSTUFF">
  <wsdlsoap:operation soapAction="GETSTUFF"/>
  <input name="GETSTUFFSRequest">
    <wsdlsoap:body use="literal"/>
  </input>
  <output name="GETSTUFFSResponse">
    <wsdlsoap:body use="literal"/>
  </output>
</operation>

The generated method looks like this client.GETSTUFF() which is not that pretty. The same goes for the complex types defined in the WSDL and the corresponding proxy classes generated when adding a service reference from Visual Studio.

So how do I control how the generated proxy classes and methods are named?

This is really more of a question for the people who wrote the service. If their operation is named GETSTUFF, then your proxy operation will be named GETSTUFF.

If you import the WSDL using wsdl.exe, you can use the /parameters command line parameter to pass an XML file with parameters. That XML file can reference a SchemaImporterExtension class. You can write a SchemaImporterExtension to format the generated code according to your wishes. See http://msdn.microsoft.com/en-us/library/system.xml.serialization.advanced.schemaimporterextension.aspx for the SchemaImporterExtension class you must inherit your implementation from, and http://msdn.microsoft.com/en-us/library/w46ccb0h.aspx for a sample program.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM