问题描述
wsdl文件:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:deFinitions
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsam="http://www.w3.org/2007/05/addressing/Metadata"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:wsa10="http://www.w3.org/2005/08/addressing"
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
xmlns:tns="http://xml.umonitor.com/uTransfer"
xmlns:cns="http://xml.umonitor.com/uTransfer/Commons"
name="uTransfer"
targetNamespace="http://xml.umonitor.com/uTransfer">
<wsdl:types>
<xsd:schema targetNamespace="http://xml.umonitor.com/uTransfer/Imports">
<xsd:import namespace="http://xml.umonitor.com/uTransfer/Commons" schemaLocation="Commons.xsd" />
<xsd:import namespace="http://xml.umonitor.com/uTransfer" schemaLocation="uTransfer.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="RefererLoginSoapIn">
<wsdl:part name="parameters" element="tns:RefererLoginRequest">
</wsdl:part>
</wsdl:message>
<wsdl:message name="RefererLoginSoapOut">
<wsdl:part name="paramaters" element="tns:RefererLoginResponse" >
</wsdl:part>
</wsdl:message>
<!-- @@@@@@@@@@@@@@ Port Type -->
<wsdl:portType name="uTransfer">
<wsdl:operation name="RefererLogin">
<wsdl:input message="tns:RefererLoginSoapIn">
</wsdl:input>
<wsdl:output message="tns:RefererLoginSoapOut">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<!-- @@@@@ binding -->
<wsdl:binding name="uTransferSOAP" type="tns:uTransfer">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="RefererLogin">
<soap:operation soapAction="http://www.umonitor.com/Authenticate/RefererLogin" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="uTransfer">
<wsdl:port name="uTransferSOAP" binding="tns:uTransferSOAP">
<soap:address location="http://uat.umonitor.com/utransferapi/services/uTransfer"/>
</wsdl:port>
</wsdl:service>
</wsdl:deFinitions>
utransfer.xsd文件
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cmn="http://xml.umonitor.com/uTransfer/Commons" xmlns:tns="http://xml.umonitor.com/uTransfer"
targetNamespace="http://xml.umonitor.com/uTransfer" elementFormDefault="qualified">
<xs:import namespace="http://xml.umonitor.com/uTransfer/Commons"
schemaLocation="Commons.xsd">
</xs:import>
<xs:element name="RefererLoginRequest" >
<xs:complexType>
<xs:sequence>
<xs:element name="Key" form="unqualified" type="xs:string" />
<xs:element name="Id" form="unqualified" type="xs:string" />
<xs:element name="UserInfo" form="unqualified" type="cmn:PersonType" />
<xs:element name="BankAccounts" form="unqualified" type="cmn:BankAccountsType" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="RefererLoginResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="Response" type="cmn:ResponseType" form="unqualified"/>
<xs:element name="TOSContentURL" type="xs:string" form="unqualified"/>
<xs:element name="SessionKey" type="xs:string" form="unqualified"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Commons.xsd文件:
<xs:schema elementFormDefault="qualified"
xmlns="http://xml.umonitor.com/uTransfer/Commons" targetNamespace="http://xml.umonitor.com/uTransfer/Commons"
xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xs:complexType name="PersonType">
<xs:sequence>
<xs:element maxOccurs="1" name="FirstName" type="xs:string" />
<xs:element maxOccurs="1" name="MiddleName" type="xs:string" />
<xs:element maxOccurs="1" name="LastName" type="xs:string" />
<xs:element maxOccurs="1" name="EmailAddress" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="ResponseType">
<xs:sequence>
<xs:element name="ResponseCode" type="xs:int" form="unqualified" />
<xs:element name="ResponseDescription" type="xs:string" form="unqualified"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="BankAccountType">
<xs:sequence>
<xs:element name="AccountId" type="xs:string" />
<xs:element name="RoutingNumber" type="xs:string" />
<xs:element name="AccountNumber" type="xs:string" />
<xs:element name="Institution" type="InstitutionType" />
<xs:element name="NameOnAccount" type="xs:string" />
<xs:element name="AccountNickName" type="xs:string" />
<xs:element name="AccountAuthStatus" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="BankAccountsType">
<xs:sequence>
<xs:element name="BankAccount" type="BankAccountType"
minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:schema>
这些是我的文件。现在我遇到的问题是前缀名称空间。例如,登录请求的响应如下:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<utr:RefererLoginResponse xmlns:utr="http://xml.umonitor.com/uTransfer">
<Response>
<ResponseCode>0</ResponseCode>
<ResponseDescription>Request processed successfully</ResponseDescription>
</Response>
<SessionKey>abcd</SessionKey>
</utr:RefererLoginResponse>
</soapenv:Body>
</soapenv:Envelope>
我遇到的问题是RefererLoginResponse的前缀名称空间。在上面的响应中,它以utr:RefererLoginResponse的形式出现。我需要没有utr的回复。我尝试将elementFormDefault指定为不合格和合格。但这并没有提供解决方案。我需要LoginRequest为合格的,这意味着具有名称空间前缀,而所有其他没有名称空间前缀的字段都是不合格的。这就是为什么我在utransfer.xsd中给了elementFormDefault =“ qualified”,然后提到所有字段都是不合格的原因。请帮助解决此问题。我真正想要的是在utransfer.xsd中进行这样的设置,这是不可能的。
解决方法
您需要将元素声明放入具有不同(或不存在)targetNamespace
的不同架构文档中,然后将两个架构文档与xs:import
声明连接起来。
全局元素声明始终位于模式的targetNamespace中。