Java 生成了错误的SOAP请求
我已经为我的WSDL生成了WSDL客户机。存根已成功生成,但当我调用服务器时,会收到下面的错误消息Java 生成了错误的SOAP请求,java,xml,web-services,soap,wsdl,Java,Xml,Web Services,Soap,Wsdl,我已经为我的WSDL生成了WSDL客户机。存根已成功生成,但当我调用服务器时,会收到下面的错误消息 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标记中而不是soapEn
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工具中尝试,它的工作方式就像charm一样。我也尝试从wsimport生成客户端,但遇到类似的问题。附加请求和响应以供参考。同时附加wsdl文件。
附加WSDL文件(因此不允许我添加整个文件,也不允许添加部分文件) 提前感谢,感谢您的帮助 Air WSDL文件
AirAbstract.wsdl
请求
回应
500
偏移量216处的未声明命名空间前缀SOAP-ENVhttp://10.7.225.35:30002/kestrel/AirService
偏移量216处的未声明命名空间前缀SOAP-ENVhttp://10.7.225.35:30002/kestrel/AirService
在SOAP请求中,SOAP-ENV
的命名空间与S
命名空间重复
<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>
至于其他名称空间,在文档中的何处声明名称空间并不重要,只要它们是在使用之前声明的
如果您发布了由CXF生成的存根代码,那么我们可能会发现问题所在。请使用使用的CXF版本更新您的问题。请更新你的wsdl,它们是不完整的。cxf-codegen-plugin是3.2.1,因此不允许我放置整个wsdl,你可以转到此链接并下载整个集合,我正在尝试Air.wsdl、SharedBooking.wsdl和Universal.wsdlI从你提供的URL下载wsdl。看起来他们发布了一个新版本(v47),我用它制作了一个模拟服务,在更新名称空间版本后,使用您的请求,它可以使用和不使用提到的标记。但是,在下载的zip文件中,SessionContext命名空间出现了一些错误。您更新了什么命名空间版本?在uAPI_WSDLschema_Release-V18.4.1.19.zip文件中,在CustomerProfileAbstract.wsdl中,SessionContext_v1_0命名空间不存在,并且在相关的导入声明(SessionContext_v1_0.xsd)中也是错误的。但是SessionContext_v1.xsd可以在zip中找到。重复使用SOAP-ENV不会导致问题,在SOAP-UI中尝试时,如果将主体复制到信封标记,则效果良好。我还想知道我是否可以控制名称空间应该出现在哪里。通过SOAP UI工作的请求示例是什么?无论哪种方式,如果问题出在生成的客户机上,那么发布代码,这可能是一个简单的解决方案,我在上面附加的请求将起作用,如果我从body标记中删除namspaces声明并将其转换为enevelope标记..前面这是在我的系统中生成请求的方式,但是在我的同事系统中,上述请求是生成的,因此它不断波动并产生恶梦。
<?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>
<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>
<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>
<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: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>