svcutil 生成不必要的包装类
我正在开发一个使用合同优先方法的项目。我获得了一个 WSDL
和三个 xsd
。当我使用 svcutil 时,它会在响应类周围生成一个包装器,如下所示:
public partial class getDataByIdResponse1 {
public getDataByIdResponse getDataByIdResponse;
public getDataByIdResponse1() {
}
public getDataByIdResponse1(getDataByIdResponse getDataByIdResponse) {
this.getDataByIdResponse = getDataByIdResponse;
}
}
getDataByIdResponse
包装在 getDataByIdResponse1
对象内。这是由 svcutil 完成的,我不知道为什么。 WSDL
中不存在 getDataByIdResponse1
对象:
<wsdl:message name="getDataById">
<wsdl:part name="response" element="tns:getDataByIdResponse"/>
</wsdl:message>
<xs:element name="getDataByIdResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="data" type="sbc:DataType" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
为什么类型 getDataByIdResponse
包装在 getDataByIdResponse1
中?我应该使用 svcutil 开关吗?
I am working on a project that uses the contract first approach. I was given a WSDL
and three xsd's
. When I use svcutil
it generates a wrapper around the response class like so:
public partial class getDataByIdResponse1 {
public getDataByIdResponse getDataByIdResponse;
public getDataByIdResponse1() {
}
public getDataByIdResponse1(getDataByIdResponse getDataByIdResponse) {
this.getDataByIdResponse = getDataByIdResponse;
}
}
The getDataByIdResponse
is wrapped inside a getDataByIdResponse1
object. This is done by svcutil
and I have no idea why. The getDataByIdResponse1
object does not exist in the WSDL
:
<wsdl:message name="getDataById">
<wsdl:part name="response" element="tns:getDataByIdResponse"/>
</wsdl:message>
<xs:element name="getDataByIdResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="data" type="sbc:DataType" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
Why is the type getDataByIdResponse
wrapped in getDataByIdResponse1
? Is there a switch for svcutil
I should have used?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我处于同样的情况(合同优先),svcutil 正在为我生成相同类型的代码,但我只是闭上眼睛深吸一口气并接受它:-)
只需使用不带数字后缀的类型,它就可以工作。
I am in the same situation (contract-first) and svcutil is generating this same kind of code for me but I just closed my eyes took a deep breath and accepted it :-)
Just use the types without the numeric postfix and it just works.