我使用 .wsdl 文件和 svcutil.exe 生成相关的 .cs 文件,生成的 .cs 文件如下:
public partial class mytargettype {
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "", Order = 0)]
[System.Xml.Serialization.XmlArrayAttribute()]
[System.Xml.Serialization.XmlArrayItemAttribute("item", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string[] prop1;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "", Order = 1)]
[System.Xml.Serialization.XmlArrayAttribute()]
[System.Xml.Serialization.XmlArrayItemAttribute("item", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string[] prop1;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "", Order = 2)]
[System.Xml.Serialization.XmlArrayAttribute()]
[System.Xml.Serialization.XmlArrayItemAttribute("item", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string[] prop3;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "", Order = 3)]
[System.Xml.Serialization.XmlArrayAttribute()]
[System.Xml.Serialization.XmlArrayItemAttribute("item", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public System.Nullable<int>[] prop4;
}
.wsdl 文件的相关部分是:
<wsdl:message name="mytargettype">
<wsdl:part name="prop1" type="ns1:stringArray" />
<wsdl:part name="prop2" type="ns1:stringArray" />
<wsdl:part name="prop3" type="ns1:stringArray" />
<wsdl:part name="prop4" type="ns1:intArray" />
</wsdl:message>
所以,我需要生成的 .cs 文件如下:
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "", Order = 2)]
[System.Xml.Serialization.XmlArrayAttribute(Namespace = "http://jaxb.dev.java.net/array")]
[System.Xml.Serialization.XmlArrayItemAttribute("item", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string[] prop3;
如您所见,我需要XmlArrayAttribute
有命名空间参数,
什么更改需要添加到 .WSDL 文件导致 .cs 文件像上面那样。