使用svcutil.exe从wsdl的+ xsd生成来自本地文件系统的文件的代码.以前用过wsdl.exe.当字段是可选的(即具有minOccurs ="0")时,如果类型是值类型(如int或enum),wsdl.exe用于生成Specified布尔值.
根据文档,当使用XmlSerializer调用时,svcutil也应该这样做,但在我的情况下它不会.这样称呼它:
svcutil WebServiceA.wsdl*.xsd/noConfig/serializer:XmlSerializer
为什么没有生成指定字段?我不想将nillable添加到wsdl中的字段,因为这意味着不同的东西,并且需要在Java后端中进行更改.
要重现的示例代码:WebServiceA.wsdl:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions targetNamespace="http://metric_web_service.uis.component.company.com/"
name="WebServiceA"
xmlns:tns="http://metric_web_service.uis.component.company.com/"
xmlns:ows="http://component_web_service.uis.component.company.com/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xsd:schema>
<xsd:import namespace="http://metric_web_service.uis.component.company.com/" schemaLocation="WebServiceA.xsd"/>
</xsd:schema>
</types>
<message name="GetDataRequest">
<part name="parameters" element="tns:getDataRequest" />
</message>
<message name="GetDataResponse">
<part name="parameters" element="tns:getDataResponse" />
</message>
<portType name="WebServiceAPortType">
<operation name="getData">
<input message="tns:GetDataRequest" />
<output message="tns:GetDataResponse" />
</operation>
</portType>
<binding name="WebServiceABinding" type="tns:WebServiceAPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="getData">
<soap:operation soapAction="getData" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="WebServiceA">
<port …Run Code Online (Sandbox Code Playgroud)