简体   繁体   English

如何设置用于生成代理类的架构

[英]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. 我正在使用WSDL,在此WSDL中定义了一些方法和类型。

Here's an example of the XML in the WSDL: 这是WSDL中XML的示例:

<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. 生成的方法看起来像这个client.GETSTUFF() ,不是那么漂亮。 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. WSDL中定义的复杂类型以及从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. 如果他们的操作名为GETSTUFF,那么您的代理操作将命名为GETSTUFF。

If you import the WSDL using wsdl.exe, you can use the /parameters command line parameter to pass an XML file with parameters. 如果使用wsdl.exe导入WSDL,则可以使用/ parameters命令行参数传递带有参数的XML文件。 That XML file can reference a SchemaImporterExtension class. 该XML文件可以引用SchemaImporterExtension类。 You can write a SchemaImporterExtension to format the generated code according to your wishes. 您可以编写SchemaImporterExtension以根据自己的意愿格式化生成的代码。 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. 请参阅http://msdn.microsoft.com/zh-cn/library/system.xml.serialization.advanced.schemaimporterextension.aspx ,以获取必须继承其实现的SchemaImporterExtension类,以及http://msdn.microsoft.com/ zh-cn / library / w46ccb0h.aspx(用于示例程序)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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