我有客户发送的WSDL文件,并给出此规则:
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://example.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="PersonInfoTransactionService" targetNamespace="http://example.com/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://example.com/" elementFormDefault="unqualified" targetNamespace="http://example.com/" version="1.0">
<xs:element name="getPersonInfo" type="tns:getPersonInfo"/>
<xs:element name="getPersonInfoResponse" type="tns:getPersonInfoResponse"/>
<xs:element name="personInfoRequest" type="tns:PersonInfoRequest"/>
<xs:element name="personInfoResponse" type="tns:PersonInfoResponse"/>
<xs:complexType name="getPersonInfo">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="PersonInfoRequest" type="tns:PersonInfoRequest"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="PersonInfoRequest">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="adress" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="dob" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="sex" type="tns:sex"/>
<xs:element minOccurs="0" maxOccurs="1" name="nationality" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getPersonInfoResponse">
<xs:sequence>
<xs:element minOccurs="0" name="PersonInfoResponse" type="tns:PersonInfoResponse"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="PersonInfoResponse">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="last_name" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="first_name" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="fathers_name" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="adress" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="dob" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="sex" type="tns:sex"/>
<xs:element minOccurs="0" maxOccurs="1" name="nationality" type="tns:nationality"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="sex">
<xs:restriction base="xs:string">
<xs:enumeration value="Male"/>
<xs:enumeration value="Female"/>
<xs:enumeration value="Unknown"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="nationality">
<xs:restriction base="xs:string">
<xs:enumeration value="AFGHANISTAN"/>
<xs:enumeration value="ALAND ISLANDS"/>
<xs:enumeration value="ALBANIA"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
</wsdl:types>
<wsdl:message name="getPersonInfoResponse">
<wsdl:part element="tns:getPersonInfoResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getPersonInfo">
<wsdl:part element="tns:getPersonInfo" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="PersonInfoTransaction">
<wsdl:operation name="getPersonInfo">
<wsdl:input message="tns:getPersonInfo" name="getPersonInfo">
</wsdl:input>
<wsdl:output message="tns:getPersonInfoResponse" name="getPersonInfoResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="PersonInfoTransactionServiceSoapBinding" type="tns:PersonInfoTransaction">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getPersonInfo">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getPersonInfo">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getPersonInfoResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PersonInfoTransactionService">
<wsdl:port binding="tns:PersonInfoTransactionServiceSoapBinding" name="PersonInfoTransactionPort">
<soap:address location="http://localhost/demo/PersonInfoTransaction"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
因此,我创建了相应的.cs文件,以便它可以为我生成上述请求的WSDL。但它生成了下面的WSDL:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http:/example.coom/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http:/example.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http:/example.com/">
<s:element name="getPersonInfo">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="personInfoRequest" type="tns:PersonInfoRequest" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="PersonInfoRequest">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="adress" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="dob" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="sex" nillable="true" type="tns:sex" />
<s:element minOccurs="0" maxOccurs="1" name="nationality" type="s:string" />
</s:sequence>
</s:complexType>
<s:simpleType name="sex">
<s:restriction base="s:string">
<s:enumeration value="Male" />
<s:enumeration value="Female" />
<s:enumeration value="Unknown" />
</s:restriction>
</s:simpleType>
<s:element name="getPersonInfoResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="getPersonInfoResult" type="tns:ArrayOfPersonInfoResponse" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfPersonInfoResponse">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="PersonInfoResponse" nillable="true" type="tns:PersonInfoResponse" />
</s:sequence>
</s:complexType>
<s:complexType name="PersonInfoResponse">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="fathers_name" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="adress" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="dob" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="sex" nillable="true" type="tns:sex" />
<s:element minOccurs="1" maxOccurs="1" name="nationality" nillable="true" type="tns:nationality" />
</s:sequence>
</s:complexType>
<s:simpleType name="nationality">
<s:restriction base="s:string">
<s:enumeration value="AFGHANISTAN" />
<s:enumeration value="ALAND ISLANDS" />
<s:enumeration value="ALBANIA" />
<s:enumeration value="ALGERIA" />
</s:restriction>
</s:simpleType>
</s:schema>
</wsdl:types>
<wsdl:message name="getPersonInfoSoapIn">
<wsdl:part name="parameters" element="tns:getPersonInfo" />
</wsdl:message>
<wsdl:message name="getPersonInfoSoapOut">
<wsdl:part name="parameters" element="tns:getPersonInfoResponse" />
</wsdl:message>
<wsdl:portType name="PersonInfoTransactionServiceSoap">
<wsdl:operation name="getPersonInfo">
<wsdl:input message="tns:getPersonInfoSoapIn" />
<wsdl:output message="tns:getPersonInfoSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="PersonInfoTransactionServiceSoap" type="tns:PersonInfoTransactionServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getPersonInfo">
<soap:operation soapAction="http:/example.com/getPersonInfo" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="PersonInfoTransactionServiceSoap12" type="tns:PersonInfoTransactionServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getPersonInfo">
<soap12:operation soapAction="http:/example.com/getPersonInfo" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PersonInfoTransactionService">
<wsdl:port name="PersonInfoTransactionServiceSoap" binding="tns:PersonInfoTransactionServiceSoap">
<soap:address location="http://localhost:7345/abc/PersonInfoTransactionService.asmx" />
</wsdl:port>
<wsdl:port name="PersonInfoTransactionServiceSoap12" binding="tns:PersonInfoTransactionServiceSoap12">
<soap12:address location="http://localhost:7345/abc/PersonInfoTransactionService.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我的主要问题是我可以直接使用WSDL而无需使用.cs文件来创建WSDL文件,或者我可以修改什么以创建标签而不是文档中的标签。或如何使用web-services
方法控制或修改WSDL?
xs and s被转换为名称空间前缀。实际的名称空间前缀无关紧要,重要的是它与。
XS指" http://www.w3.org/2001/xmlschema"(XMLNS:XS =" http://www.w3.org/2001/xmlschema"(S还指相同的名称空间(XMLNS:s =" http://www.w3.org/2001/xmlschema"(
s或xs应该无关紧要。