有1个WSDL和一些XSD文件。一旦尝试使用此wsdl和SOAPUI发送请求,我就能够成功发送请求和响应。
WSDL:
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="FIGetAcctsInfoCallBack" targetNamespace="http://www.sama.bea.sa/inquiry/services/FIGetAcctsInfoCallBack/" xmlns:gs-ai="http://www.sama.bea.sa/inquiry/services/FIGetAcctsInfo" xmlns:head="http://www.sama.bea.sa/common/Header" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wair="http://www.sama.bea.sa/inquiry/services/FIGetAcctsInfoCallBack/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema targetNamespace="http://www.sama.bea.sa/inquiry/FIGetAcctsInfoCallBack/">
<xsd:import namespace="http://www.sama.bea.sa/common/Header" schemaLocation="../../common/Header.xsd"/>
<xsd:import namespace="http://www.sama.bea.sa/inquiry/services/FIGetAcctsInfo" schemaLocation="../services/FIGetAcctsInfo.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="FIGetAcctsInfoCallBackRq">
<wsdl:part element="gs-ai:FIGetAcctsInfoCallBackRq" name="parameters"/>
</wsdl:message>
<wsdl:message name="FIGetAcctsInfoCallBackRs">
<wsdl:part element="gs-ai:FIGetAcctsInfoCallBackRs" name="parameters"/>
</wsdl:message>
<wsdl:message name="RqHdr">
<wsdl:part element="head:MsgHdrRq" name="header"/>
</wsdl:message>
<wsdl:message name="RsHdr">
<wsdl:part element="head:MsgHdrRs" name="header"/>
</wsdl:message>
<wsdl:portType name="FIGetAcctsInfoCallBack">
<wsdl:operation name="FIGetAcctsInfoCallBack">
<wsdl:input message="wair:FIGetAcctsInfoCallBackRq"/>
<wsdl:output message="wair:FIGetAcctsInfoCallBackRs"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="FIGetAcctsInfoCallBackSOAP" type="wair:FIGetAcctsInfoCallBack">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="FIGetAcctsInfoCallBack">
<soap:operation soapAction="http://www.sama.bea.sa/inquiry/FIGetAcctsInfoCallBack/FIGetAcctsInfoCallBack"/>
<wsdl:input>
<soap:body use="literal"/>
<soap:header message="wair:RqHdr" part="header" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
<soap:header message="wair:RsHdr" part="header" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="FIGetAcctsInfoCallBack">
<wsdl:port binding="wair:FIGetAcctsInfoCallBackSOAP" name="FIGetAcctsInfoCallBackSOAP">
<soap:address location="http://www.sama.bea.sa/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://www.sama.bea.sa/inquiry/services/FIGetAcctsInfo"
xmlns:gi-lib="http://www.sama.bea.sa/inquiry/services/GeneralInquiryLib"
xmlns:ai="http://www.sama.bea.sa/inquiry/services/FIGetAcctsInfo"
xmlns:base="http://www.sama.bea.sa/common/BaseLib">
<xsd:import namespace="http://www.sama.bea.sa/common/BaseLib"
schemaLocation="../../common/BaseLib.xsd" />
<xsd:import
namespace="http://www.sama.bea.sa/inquiry/services/GeneralInquiryLib"
schemaLocation="GeneralInquiryLib.xsd" />
<xsd:element name="FIGetAcctsInfoRq" type="ai:T_FIGetAcctsInfoRq">
</xsd:element>
<xsd:element name="FIGetAcctsInfoRs" type="ai:T_FIGetAcctsInfoRs">
</xsd:element>
<xsd:element name="FIGetAcctsInfoCallBackRq" type="ai:T_FIGetAcctsInfoCallBackRq">
</xsd:element>
<xsd:element name="FIGetAcctsInfoCallBackRs" type="ai:T_FIGetAcctsInfoCallBackRs">
</xsd:element>
<xsd:complexType name="T_FIGetAcctsInfoRq">
<xsd:sequence>
<xsd:element name="Rqstr" type="base:T_Rqstr" maxOccurs="1" minOccurs="1" ></xsd:element>
<xsd:element name="InvPrty" type="base:T_InvPrty" maxOccurs="1" minOccurs="0"></xsd:element>
<xsd:element name="ThrdPrty" type="base:T_ThrdPrty" maxOccurs="1" minOccurs="0"></xsd:element>
<xsd:element name="AccQry" type="gi-lib:T_AccQry" maxOccurs="1" minOccurs="0"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="T_FIGetAcctsInfoRs">
</xsd:complexType>
<xsd:complexType name="T_FIGetAcctsInfoCallBackRq">
<xsd:sequence>
<xsd:element name="AcctsList" type="gi-lib:T_AcctsList" maxOccurs="1" minOccurs="0"></xsd:element>
<xsd:element name="ShrsList" type="base:T_ShrsList" maxOccurs="1" minOccurs="0"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="T_FIGetAcctsInfoCallBackRs">
</xsd:complexType>
</xsd:schema>
以下请求是由SOAPUI创建的。 (成功案例)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:head="http://www.sama.bea.sa/common/Header"
xmlns:bas="http://www.sama.bea.sa/common/BaseLib"
xmlns:fig="http://www.sama.bea.sa/inquiry/services/FIGetAcctsInfo"
xmlns:gen="http://www.sama.bea.sa/inquiry/services/GeneralInquiryLib">
<soapenv:Header>
<head:MsgHdrRq>
<head:PID>90084</head:PID>
<head:MsgDtTm>2019-03-25T10:02:26</head:MsgDtTm>
<head:ChID>B2B</head:ChID>
<head:MsgUID>ACCINFO_20190415_636909521492188253</head:MsgUID>
<head:SRN>1800010204898</head:SRN>
<head:Cnfd>1</head:Cnfd>
<head:Mod>0</head:Mod>
<head:CRN>1800010204898-S27614262382881570612-01</head:CRN>
<head:Clsf>R1</head:Clsf>
<head:pHash>kjhvsd</head:pHash>
<head:Status>S9000001</head:Status>
</head:MsgHdrRq>
</soapenv:Header>
<soapenv:Body>
<fig:FIGetAcctsInfoCallBackRq>
</fig:FIGetAcctsInfoCallBackRq>
</soapenv:Body>
</soapenv:Envelope>
我只想在C#应用程序中使用相同的wsdl来调用Web服务。我使用“添加服务参考”选项并显示wsdl路径,服务已成功添加。之后,我得到了相同参数的错误。我调查了与 IClientMessageInspector 一起使用的问题,并且可以看到Visual Studio准备的请求。以下是Visual Studio 2017准备的请求
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://www.sama.bea.sa/inquiry/FIGetAcctsInfoCallBack/FIGetAcctsInfoCallBack</Action>
<h:MsgHdrRq xmlns="http://www.sama.bea.sa/common/Header" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://www.sama.bea.sa/common/Header">
<PID>90010</PID>
<MsgDtTm>2019-05-16T11:24:06</MsgDtTm>
<ChID>B2B</ChID>
<MsgUID>1_20190516_636936026996740956</MsgUID>
<SRN>1900010002766</SRN>
<Cnfd>1</Cnfd>
<Mod>0</Mod>
<CRN>1900010002766-S36085627909222179147</CRN>
<Clsf>R1</Clsf>
<IPAdrs>100.100.185.100</IPAdrs>
<Status>S9000001</Status>
</h:MsgHdrRq>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<FIGetAcctsInfoCallBackRq xmlns="http://www.sama.bea.sa/inquiry/services/FIGetAcctsInfo" />
</s:Body>
</s:Envelope>
如果比较SOAPUI和Visual Studio准备的2个差异,则可以看到差异。
-名称空间不正确(MsgHdrRq标签不应具有名称空间属性)
-缺少一些前缀(<** head:** PID ...
-Envelope标签应具有名称空间属性,如下面的代码所示。
由于这些差异,我遇到了错误。您是否有像SOAPUI中一样生成相同请求的解决方案?