首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >生成了错误的SOAP请求

生成了错误的SOAP请求
EN

Stack Overflow用户
提问于 2019-01-07 00:40:25
回答 1查看 0关注 0票数 0

我为我的WSDL 生成了WSDL客户端。存根成功生成但是当我调用服务器时,我得到以下错误消息

代码语言:javascript
复制
undeclared namespace prefix SOAP-ENV at offset 216 of http://10.7.225.35:30002/kestrel/AirService

This is to stop the scroll bar obscuring the text 

当生成请求时,我可以看到targetnamespaces被添加到body标签而不是soapEnvelope标签中,如果我手动更改它并在SOAPUI工具中尝试它,它就会出错。我尝试从wsimport生成客户端,但是遇到了类似的问题。附加请求和响应以供参考。还附加wsdl文件。 附加WSDL文件(所以不允许我添加整个,所以添加部分) 求助谢谢!

Air WSDL文件

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="AirService"
             xmlns="http://schemas.xmlsoap.org/wsdl/"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:tns="http://www.travelport.com/service/air_v46_0"
             xmlns:ns1="http://www.travelport.com/schema/air_v46_0"
             targetNamespace="http://www.travelport.com/service/air_v46_0">

    <import namespace="http://www.travelport.com/service/air_v46_0"
          location="AirAbstract.wsdl" />

     <binding name="AirPrePayBinding"
             type="tns:AirPrePayPortType">
        <soap:binding style="document"
                      transport="http://schemas.xmlsoap.org/soap/http" />
        <operation name="service">
            <soap:operation soapAction="http://localhost:8080/kestrel/AirService"/>
                <input>
                    <soap:body use="literal" />
                </input>
                <output>
                    <soap:body use="literal" />
                </output>
                <fault name="ErrorInfoMsg">
                    <soap:fault name="ErrorInfoMsg" use="literal" />
                </fault>

        </operation>
    </binding>

AirAbstract.wsdl

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>

<definitions name="AirService"
             xmlns="http://schemas.xmlsoap.org/wsdl/"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:tns="http://www.travelport.com/service/air_v46_0"
             xmlns:ns1="http://www.travelport.com/schema/air_v46_0"
             targetNamespace="http://www.travelport.com/service/air_v46_0">

    <import namespace="http://www.travelport.com/service/air_v46_0"
          location="AirAbstract.wsdl" />

     <binding name="AirPrePayBinding"
             type="tns:AirPrePayPortType">
        <soap:binding style="document"
                      transport="http://schemas.xmlsoap.org/soap/http" />
        <operation name="service">
            <soap:operation soapAction="http://localhost:8080/kestrel/AirService"/>
                <input>
                    <soap:body use="literal" />
                </input>
                <output>
                    <soap:body use="literal" />
                </output>
                <fault name="ErrorInfoMsg">
                    <soap:fault name="ErrorInfoMsg" use="literal" />
                </fault>

        </operation>
    </binding>     

request

代码语言:javascript
复制
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header />
    <S:Body xmlns:ns1="http://www.travelport.com/schema/air_v46_0" xmlns:ns2="http://www.travelport.com/schema/common_v46_0" xmlns:ns3="http://www.travelport.com/schema/vehicle_v46_0" xmlns:ns4="http://www.travelport.com/schema/rail_v46_0" xmlns:ns5="http://www.travelport.com/schema/cruise_v46_0" xmlns:ns6="http://www.travelport.com/schema/hotel_v46_0" xmlns:ns7="http://www.travelport.com/schema/passive_v46_0" xmlns:ns8="http://www.travelport.com/schema/universal_v46_0" xmlns:ns9="http://www.travelport.com/soa/common/security/SessionContext_v1">
        <ns1:LowFareSearchReq ReturnUpsellFare="true" TargetBranch="P7111432">
            <ns2:BillingPointOfSaleInfo OriginApplication="UAPI" />
            <ns1:SearchAirLeg>
                <ns1:SearchOrigin>
                    <ns2:CityOrAirport Code="BLR" />
                </ns1:SearchOrigin>
                <ns1:SearchDestination>
                    <ns2:CityOrAirport Code="JAI" />
                </ns1:SearchDestination>
                <ns1:SearchDepTime PreferredTime="2019-03-22" />
                <ns1:AirLegModifiers>
                    <ns1:PermittedCabins>
                        <ns2:CabinClass Type="Economy" />
                    </ns1:PermittedCabins>
                </ns1:AirLegModifiers>
            </ns1:SearchAirLeg>
            <ns1:AirSearchModifiers>
                <ns1:PreferredProviders>
                    <ns2:Provider Code="1G" />
                </ns1:PreferredProviders>
            </ns1:AirSearchModifiers>
            <ns2:SearchPassenger Code="ADT" />
            <ns2:SearchPassenger Code="INF" PricePTCOnly="true" />
            <ns2:SearchPassenger Code="CNN" />
            <ns1:AirPricingModifiers CurrencyType="INR" FaresIndicator="AllFares" />
        </ns1:LowFareSearchReq>
    </S:Body>
</S:Envelope>

响应

代码语言:javascript
复制
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Header />
    <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
            <SOAP-ENV:faultcode>500</SOAP-ENV:faultcode>
            <SOAP-ENV:faultstring>undeclared namespace prefix SOAP-ENV at offset 216 of http://10.7.225.35:30002/kestrel/AirService</SOAP-ENV:faultstring>
            <SOAP-ENV:faultactor></SOAP-ENV:faultactor>
            <SOAP-ENV:detail>undeclared namespace prefix SOAP-ENV at offset 216 of http://10.7.225.35:30002/kestrel/AirService</SOAP-ENV:detail>
        </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
EN

回答 1

Stack Overflow用户

发布于 2019-01-07 09:52:40

在SOAP请求中,名称空间SOAP-ENV是命名空间的副本S

代码语言:javascript
复制
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header />
    <S:Body xmlns:ns1="http://www.travelport.com/schema/air_v46_0" >

... snip ...

</S:Envelope>

我猜解析器不喜欢重复的名称空间前缀,所以更改请求以S用作标头的前缀(或删除它,因为它没有填充)

代码语言:javascript
复制
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" >    
    <S:Header />
    <S:Body xmlns:ns1="http://www.travelport.com/schema/air_v46_0" >

</S:Envelope>

至于其他命名空间,只要在使用它们之前声明它们,就应该在文档中的哪个位置声明命名空间。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100008950

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档