无法调用https Web服务

时间:2019-04-16 11:39:11

标签: c# web-services soapui

有一个Web服务,可以在Visual Studio中成功使用SOAPUI调用。这两个Web服务客户端都是由我在下面共享的xml(wsdl和xsd)生成的。

下面的屏幕截图显示了我如何在SOAPUI中成功调用Web服务。 enter image description here

当我尝试使用相同的wsdl和xsd文件尝试相同的Web服务时,出现以下错误。

The content type text/html of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 768 bytes of the response were: '<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:date="http://exslt.org/dates-and-times" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><env:Fault><faultcode>E9810004</faultcode><faultstring>Schema Validation Error</faultstring><detail>https://10.152.29.21:443/bea/ws/gi/fi/getbalsinfocallback/v01: cvc-particle 3.1: in element {http://schemas.xmlsoap.org/soap/envelope/}Body of type {http://schemas.xmlsoap.org/soap/envelope/}Body, found &lt;NS3:FIGetBalsInfoCallBackRs> (in namespace http://www.sama.bea.sa/inquiry/FIGetBalsInfo), but next item should be any of [{http://schemas.xmlsoap.org/soap/envelope/}Fault, {http://www.sama.bea.sa/inquiry/services/FIGetBalsInfo}FIGetBalsInfoCallBackRs]</detail></env:Fault></env:Body></env:Envelope>'.

enter image description here

Webservice wsdl:

    <?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="FIGetBalsInfoCallBack"
    targetNamespace="http://www.sama.bea.sa/inquiry/services/FIGetBalsInfoCallBack" xmlns:bi="http://www.sama.bea.sa/inquiry/services/FIGetBalsInfo"
    xmlns:head="http://www.sama.bea.sa/common/Header" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wbir="http://www.sama.bea.sa/inquiry/services/FIGetBalsInfoCallBack"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <wsdl:types>
        <xsd:schema>
            <xsd:import namespace="http://www.sama.bea.sa/inquiry/services/FIGetBalsInfo" schemaLocation="../services/FIGetBalsInfo.xsd" />
            <xsd:import namespace="http://www.sama.bea.sa/common/Header" schemaLocation="../../common/Header.xsd" />
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="FIGetBalsInfoCallBackRq">
        <wsdl:part element="bi:FIGetBalsInfoCallBackRq" name="parameters" />
    </wsdl:message>
    <wsdl:message name="FIGetBalsInfoCallBackRs">
        <wsdl:part element="bi:FIGetBalsInfoCallBackRs" 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="FIGetBalsInfoCallBack">
        <wsdl:operation name="FIGetBalsInfoCallBack">
            <wsdl:input message="wbir:FIGetBalsInfoCallBackRq" />
            <wsdl:output message="wbir:FIGetBalsInfoCallBackRs" />
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="FIGetBalsInfoCallBackSOAP" type="wbir:FIGetBalsInfoCallBack">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="FIGetBalsInfoCallBack">
            <soap:operation soapAction="http://www.sama.bea.sa/inquiry/FIGetBalsInfoCallBack/FIGetBalsInfoCallBack" />
            <wsdl:input>
                <soap:body use="literal" />
                <soap:header message="wbir:RqHdr" part="header" use="literal" />
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" />
                <soap:header message="wbir:RsHdr" part="header" use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="FIGetBalsInfoCallBack">
        <wsdl:port binding="wbir:FIGetBalsInfoCallBackSOAP" name="FIGetBalsInfoCallBackSOAP">
            <soap:address location="http://www.sama.bea.sa/" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

Xsd 1:

<?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/FIGetBalsInfo"
    xmlns:base="http://www.sama.bea.sa/common/BaseLib"
    xmlns:bi="http://www.sama.bea.sa/inquiry/services/FIGetBalsInfo"
    xmlns:gi-lib="http://www.sama.bea.sa/inquiry/services/GeneralInquiryLib">
    <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="FIGetBalsInfoRq" type="bi:T_FIGetBalsInfoRq">
    </xsd:element>
    <xsd:element name="FIGetBalsInfoRs" type="bi:T_FIGetBalsInfoRs"></xsd:element>
    <xsd:element name="FIGetBalsInfoCallBackRq" type="bi:T_FIGetBalsInfoCallBackRq"></xsd:element>
    <xsd:element name="FIGetBalsInfoCallBackRs" type="bi:T_FIGetBalsInfoCallBackRs"></xsd:element>
    <xsd:complexType name="T_FIGetBalsInfoRq">
        <xsd:sequence>
            <xsd:element maxOccurs="1" minOccurs="1" name="Rqstr" type="base:T_Rqstr"> </xsd:element>
            <xsd:element maxOccurs="1" minOccurs="0" name="InvPrty" type="base:T_InvPrty"></xsd:element>
            <xsd:element maxOccurs="1" minOccurs="0" name="ThrdPrty" type="base:T_ThrdPrty"></xsd:element>
            <xsd:element maxOccurs="1" minOccurs="0" name="AccQry" type="gi-lib:T_AccQry"></xsd:element>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="T_FIGetBalsInfoRs">
    </xsd:complexType>
    <xsd:complexType name="T_FIGetBalsInfoCallBackRq">
        <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_FIGetBalsInfoCallBackRs">
    </xsd:complexType>
</xsd:schema>

Xsd 2:

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.sama.bea.sa/inquiry/services/GeneralInquiryLib" elementFormDefault="qualified"
    xmlns="http://www.w3.org/2001/XMLSchema" xmlns:base="http://www.sama.bea.sa/common/BaseLib" xmlns:gi-lib="http://www.sama.bea.sa/inquiry/services/GeneralInquiryLib">
    <import schemaLocation="../../common/BaseLib.xsd" namespace="http://www.sama.bea.sa/common/BaseLib"></import>
    <complexType name="T_FIRsGetAcctsInfo">
        <sequence>
            <element name="FICode" minOccurs="1" maxOccurs="1">
                <simpleType>
                    <restriction base="string">
                        <length value="5" />
                    </restriction>
                </simpleType>
            </element>
            <element name="FIRsStatus" type="base:T_StatusCode" maxOccurs="1" minOccurs="1" ></element>
            <element name="AcctsList" type="gi-lib:T_AcctsList" maxOccurs="1" minOccurs="0"></element>
            <element name="ShrsList" type="base:T_ShrsList" maxOccurs="1" minOccurs="0"></element>
        </sequence>
     </complexType>
    <complexType name="T_FIRsGetBalsInfo">
        <sequence>
            <element name="FICode" minOccurs="1" maxOccurs="1">
                <simpleType>
                    <restriction base="string">
                        <length value="5" />
                    </restriction>
                </simpleType>
            </element>
            <element name="FIRsStatus" type="base:T_StatusCode" maxOccurs="1" minOccurs="1"></element>
            <element name="AcctsList" type="gi-lib:T_AcctsList" maxOccurs="1" minOccurs="0"></element>
            <element name="ShrsList" type="base:T_ShrsList" maxOccurs="1" minOccurs="0"></element>
        </sequence>
     </complexType>
    <complexType name="T_AccQry">
        <sequence>
            <element name="AccNum" type="base:T_AccountNumber" minOccurs="1" maxOccurs="1"></element>
            <element name="IBAN" type="base:T_Flag" minOccurs="1" maxOccurs="1"></element>
        </sequence>
    </complexType>
    <complexType name="T_AcctsList">
        <sequence>
            <element name="AccInfo" type="gi-lib:T_AccountInfo" minOccurs="1" maxOccurs="unbounded"></element>
        </sequence>
    </complexType>
    <complexType name="T_AccountInfo">
        <sequence>         
            <element name="AccNum" type="base:T_AccountNumber" minOccurs="1" maxOccurs="1"></element>
            <element name="IBAN" type="base:T_IBAN" minOccurs="0" maxOccurs="1"></element>
            <element name="AccType" minOccurs="0" maxOccurs="1">
                <simpleType>
                    <restriction base="base:T_NSPC">
                        <minLength value="1" />
                        <maxLength value="20" />
                    </restriction>
                </simpleType>
            </element>
            <element name="JntAcc" type="base:T_Flag" minOccurs="1" maxOccurs="1"></element>
            <element name="AccCur" type="base:T_AccCur" minOccurs="0" maxOccurs="1"></element>
            <element name="AccStatus" type="base:T_AccStatus" minOccurs="0" maxOccurs="1"></element>
            <element name="Inst" type="base:T_FullName" minOccurs="0" maxOccurs="1"></element>
            <element name="OpnDt" type="base:T_date" minOccurs="0" maxOccurs="1"></element>
            <element name="ClsDt" type="base:T_date" minOccurs="0" maxOccurs="1"></element>
            <element name="AvailBal" type="base:T_Balance" minOccurs="0" maxOccurs="1"></element>          
            <element name="TotBal" type="base:T_Balance" minOccurs="0" maxOccurs="1"></element>
             <element name="BalDt" type="base:T_date" minOccurs="0" maxOccurs="1"></element>
            <element name="PrdUsrsList" type="base:T_PrdUsrsLis" minOccurs="1" maxOccurs="1"></element>
           <element name="RsrvList" type="base:T_RsrvList" minOccurs="0" maxOccurs="1"></element>
        </sequence>
    </complexType>
    <complexType name="T_FIRsGetDepotsInfo">
        <sequence>
            <element name="FICode" minOccurs="1" maxOccurs="1">
                <simpleType>
                    <restriction base="string">
                        <length value="5" />
                    </restriction>
                </simpleType>
            </element>
            <element name="FIRsStatus" type="base:T_StatusCode" maxOccurs="1" minOccurs="1"></element>
            <element name="DepotsList" type="gi-lib:T_DepotsList" maxOccurs="1" minOccurs="0"></element>
        </sequence>
     </complexType>
    <complexType name="T_DepotsList">
        <sequence>
            <element name="DepotInfo" type="gi-lib:T_DepotInfo" minOccurs="1" maxOccurs="unbounded"></element>
        </sequence>
    </complexType>
    <complexType name="T_DepotInfo">
        <sequence>
            <element name="DepotNum" minOccurs="1" maxOccurs="1">
                <simpleType>
                    <restriction base="base:T_NSPC_Text">
                        <minLength value="1" />
                        <maxLength value="30" />
                    </restriction>
                </simpleType>
            </element>
            <element name="DepotType" minOccurs="0" maxOccurs="1">
                <simpleType>
                    <restriction base="base:T_AnyType">
                        <minLength value="1" />
                        <maxLength value="200" />
                    </restriction>
                </simpleType>
            </element>
            <element name="JntAcc" type="base:T_Flag" minOccurs="1" maxOccurs="1"></element>
            <element name="DepotCur" type="base:T_AccCur" minOccurs="0" maxOccurs="1"></element>
            <element name="DepotStatus" type="base:T_DepotStatus" minOccurs="0" maxOccurs="1"></element>
            <element name="DepotStrtDt" type="base:T_date" minOccurs="0" maxOccurs="1"></element>
            <element name="DepotDueDt" type="base:T_date" minOccurs="0" maxOccurs="1">
            </element>
            <element name="DepotBal" type="base:T_Balance" minOccurs="0" maxOccurs="1"></element>
            <element name="PrdUsrsList" type="base:T_PrdUsrsLis" minOccurs="1" maxOccurs="1">
            </element>
        </sequence>
    </complexType>
    <complexType name="T_FIRsGetLiabsInfo">
        <sequence>
            <element name="FICode" minOccurs="1" maxOccurs="1">
                <simpleType>
                    <restriction base="string">
                        <length value="5" />
                    </restriction>
                </simpleType>
            </element>
            <element name="FIRsStatus" type="base:T_StatusCode" maxOccurs="1" minOccurs="1"></element>
            <element name="LiabsList" type="gi-lib:T_LiabsList" maxOccurs="1" minOccurs="0"></element>
        </sequence>
     </complexType>
    <complexType name="T_LiabsList">
        <sequence>
            <element name="LiabInfo" type="gi-lib:T_LiabInfo" minOccurs="1" maxOccurs="unbounded"></element>
        </sequence>
    </complexType>
    <complexType name="T_LiabInfo">
        <sequence>
            <element name="AccNum" type="base:T_AccountNumber" minOccurs="0" maxOccurs="1"></element>
             <element name="IBAN" type="base:T_IBAN" minOccurs="0" maxOccurs="1"></element>
            <element name="LiabType" minOccurs="1" maxOccurs="1">
                <simpleType>
                    <restriction base="base:T_AnyType">
                        <minLength value="1" />
                        <maxLength value="200" />
                    </restriction>
                </simpleType>
            </element>
            <element name="LiabCur" type="base:T_AccCur" minOccurs="1" maxOccurs="1"></element>
            <element name="LiabInstsNum"  minOccurs="1" maxOccurs="1">
            <simpleType>
                    <restriction base="string">
                        <minLength value="1" />
                        <maxLength value="5" />
                        <pattern value="[0-9]+" /> 
                    </restriction>
                </simpleType>
            </element>
            <element name="InstRept" type="base:T_InstRept" minOccurs="1" maxOccurs="1"></element>
           <element name="InstReptTms" type="base:T_InstReptTms" minOccurs="1" maxOccurs="1"></element>
            <element name="InstAmt" type="base:T_BaseAmt" minOccurs="1" maxOccurs="1"></element>
            <element name="LstPymtDt" type="base:T_date" minOccurs="0" maxOccurs="1"></element>
            <element name="LiabDueDt" type="base:T_date" minOccurs="1" maxOccurs="1"></element>
            <element name="TotLiabAmt" type="base:T_Balance" minOccurs="1" maxOccurs="1"></element>
            <element name="RmngLiabAmt" type="base:T_Balance" minOccurs="1" maxOccurs="1"></element>
            <element name="PrdUsrsList" type="base:T_PrdUsrsLis" minOccurs="1" maxOccurs="1"></element>
        </sequence>
    </complexType>
    <complexType name="T_FIRsGetSafsInfo">
        <sequence>
            <element name="FICode" minOccurs="1" maxOccurs="1">
                <simpleType>
                    <restriction base="string">
                        <length value="5" />
                    </restriction>
                </simpleType>
            </element>
            <element name="FIRsStatus" type="base:T_StatusCode" maxOccurs="1" minOccurs="1"></element>
            <element name="SafsList" type="gi-lib:T_SafsList" maxOccurs="1" minOccurs="0"></element>
        </sequence>
    </complexType>
    <complexType name="T_SafsList">
        <sequence>
            <element name="SafInfo" type="gi-lib:T_SafInfo" minOccurs="1" maxOccurs="unbounded"></element>
        </sequence>
    </complexType>
    <complexType name="T_SafInfo">
        <sequence>
            <element name="SafNum" minOccurs="1" maxOccurs="1">
                <simpleType>
                    <restriction base="base:T_NSPC_Text">
                        <minLength value="1" />
                        <maxLength value="30" />
                    </restriction>
                </simpleType>
            </element>
            <element name="JntAcc" type="base:T_Flag" minOccurs="1" maxOccurs="1"></element>
            <element name="SafBrnch" minOccurs="0" maxOccurs="1">
                <simpleType>
                    <restriction base="base:T_AnyName">
                        <minLength value="1" />
                        <maxLength value="200" />
                    </restriction>
                </simpleType>
            </element>
            <element name="OpnDt" type="base:T_date" minOccurs="0" maxOccurs="1"></element>
            <element name="PrdUsrsList" type="base:T_PrdUsrsLis" minOccurs="1" maxOccurs="1">
            </element>
        </sequence>
    </complexType>
</schema>

1 个答案:

答案 0 :(得分:1)

从您的代码示例中可以看出,尽管屏幕截图非常小,但难以读取,但确实显示您没有通过infoRequestCB,而只是通过了标头。您收到的消息表明该请求缺少它需要的内容-这将是显而易见的地方。调用FIGetBalsInfoCallBack时,传递正文对象和标题。

顺便说一句,由于几个不同的原因,您正在调用的服务看起来完全是垃圾:

  • 究竟是谁设计了一个SOAP服务,以使其在SOAP标头中的所有参数都为空?
  • 将SOAP错误的格式设置为text/html,这是完全错误的。