从Java客户端获取SOAP服务的响应时,我遇到了以下错误:
[javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.carefirst.com/Enterprise/DAC/AddressRetrievalSchema", local:"AddressInfoResponse"). Expected elements are (none)]
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:447)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:372)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:342)
但是我能够成功地从Eclipse连接到服务,但是当将jar部署到我的webshere服务器时,我收到了这个错误。
没有服务端,它能够成功发送以下响应:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:AddressInfoOut xmlns:ns0="http://www.carefirst.com/Enterprise/DAC/DACStatusService">
<Output>
<ns1:AddressInfoResponse xmlns:ns1="http://www.carefirst.com/Enterprise/DAC/AddressRetrievalSchema">
<ns1:Success>true</ns1:Success>
<ns1:docProp>
<ns1:Property PropertyName="BTCH_ID">222EOB222</ns1:Property>
<ns1:Property PropertyName="outbound address line1">103 North Washington Street</ns1:Property>
<ns1:Property PropertyName="outbound address city">Suitland</ns1:Property>
<ns1:Property PropertyName="mail forwarding address line1">103 N WASHINGTON ST</ns1:Property>
<ns1:Property PropertyName="mail forwarding address city">BRYANS ROAD</ns1:Property>
<ns1:Property PropertyName="fiserv status">mailed</ns1:Property>
</ns1:docProp>
</ns1:AddressInfoResponse>
</Output>
</ns0:AddressInfoOut>
WSDL
<?xml version="1.0" encoding="UTF-8"?>
<!--Created by TIBCO WSDL-->
<wsdl:definitions xmlns:ns2="http://www.carefirst.com/Enterprise/DAC/AddressRetrievalSchema" xmlns:ns1="http://carefirst.com/Enterprise/Operations/SoapFault" xmlns:tns="http://www.carefirst.com/Enterprise/DAC/DACStatusService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns0="http://www.carefirst.com/Enterprise/DAC/StatusRetrievalSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="Untitled" targetNamespace="http://www.carefirst.com/Enterprise/DAC/DACStatusService">
<wsdl:types>
<xs:schema xmlns="http://www.carefirst.com/Enterprise/DAC/AddressRetrievalSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.carefirst.com/Enterprise/DAC/AddressRetrievalSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xs:element name="AddressInfoRequest">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns2:header" minOccurs="0"/>
<xs:element ref="ns2:body"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="AddressInfoResponse">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns2:Success"/>
<xs:element ref="ns2:docProp"/>
<xs:element ref="ns2:Error" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="BatchID" type="xs:string"/>
<xs:element name="Error">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns2:msgCode" minOccurs="0"/>
<xs:element ref="ns2:msg" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Success" type="xs:boolean"/>
<xs:element name="TransactionID" type="xs:string"/>
<xs:element name="body">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns2:BatchID"/>
<xs:element ref="ns2:TransactionID"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="docProp">
<xs:complexType>
<xs:sequence>
<xs:element name="Property" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="PropertyName" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="header" type="xs:string"/>
<xs:element name="msg" type="xs:string"/>
<xs:element name="msgCode" type="xs:string"/>
</xs:schema>
<xsd:schema xmlns="http://carefirst.com/Enterprise/Operations/SoapFault" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://carefirst.com/Enterprise/Operations/SoapFault" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xsd:element name="fault">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="faultType" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="SystemUnavailableFault" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="msg" type="xsd:string" minOccurs="0"/>
<xsd:element name="msgCode" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="SourceSystemInvalid" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="msg" type="xsd:string" minOccurs="0"/>
<xsd:element name="msgCode" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="DataNotFound" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="msg" type="xsd:string" minOccurs="0"/>
<xsd:element name="msgCode" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ApplicationException" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="msg" type="xsd:string" minOccurs="0"/>
<xsd:element name="msgCode" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="SystemTimeOutException" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="msg" type="xsd:string" minOccurs="0"/>
<xsd:element name="msgCode" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="PackageNotCompiled" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="msg" type="xsd:string" minOccurs="0"/>
<xsd:element name="msgCode" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="AuthenticationException" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="msg" type="xsd:string" minOccurs="0"/>
<xsd:element name="msgCode" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="InputDataInvalid" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="msg" type="xsd:string" minOccurs="0"/>
<xsd:element name="msgCode" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="DefaultFault" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="faultCode" type="xsd:string" minOccurs="0"/>
<xsd:element name="faultMsg" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xs:schema xmlns="http://www.carefirst.com/Enterprise/DAC/StatusRetrievalSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.carefirst.com/Enterprise/DAC/StatusRetrievalSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xs:element name="BatchID" type="xs:string"/>
<xs:element name="CDWBatchID" type="xs:string"/>
<xs:element name="Error">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns0:msgCode" minOccurs="0"/>
<xs:element ref="ns0:msg" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="StatusRequest">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns0:header" minOccurs="0"/>
<xs:element ref="ns0:body"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="StatusResponse">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns0:Success"/>
<xs:element ref="ns0:docProp"/>
<xs:element ref="ns0:Error" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Success" type="xs:boolean"/>
<xs:element name="TransactionID" type="xs:string"/>
<xs:element name="body">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns0:BatchID" minOccurs="0"/>
<xs:element ref="ns0:CDWBatchID" minOccurs="0"/>
<xs:element ref="ns0:TransactionID" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="docProp">
<xs:complexType>
<xs:sequence>
<xs:element name="Property" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="PropertyName" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="header">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns0:senderID" minOccurs="0"/>
<xs:element ref="ns0:senderApp" minOccurs="0"/>
<xs:element ref="ns0:msgID" minOccurs="0"/>
<xs:element ref="ns0:msgVersion" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="msg" type="xs:string"/>
<xs:element name="msgCode" type="xs:string"/>
<xs:element name="msgID" type="xs:string"/>
<xs:element name="msgVersion" type="xs:string"/>
<xs:element name="senderApp" type="xs:string"/>
<xs:element name="senderID" type="xs:string"/>
</xs:schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/XML/1998/namespace" elementFormDefault="unqualified" attributeFormDefault="qualified">
<attribute name="base" type="anyURI"/>
<attribute name="id" type="ID"/>
<attribute name="lang">
<simpleType>
<union memberTypes="language">
<simpleType>
<restriction base="string">
<length value="0"/>
</restriction>
</simpleType>
</union>
</simpleType>
</attribute>
<attribute name="space" default="preserve">
<simpleType>
<restriction base="NCName">
<enumeration value="default"/>
<enumeration value="preserve"/>
</restriction>
</simpleType>
</attribute>
<attributeGroup name="specialAttrs">
<attribute ref="xml:base"/>
<attribute ref="xml:id"/>
<attribute ref="xml:lang"/>
<attribute ref="xml:space" default="preserve"/>
</attributeGroup>
</schema>
</wsdl:types>
<wsdl:service name="DACStatusService">
<wsdl:port name="StatusandAddressRetrievalPortEndpoint1" binding="tns:StatusandAddressRetrievalPortEndpoint1Binding">
<soap:address location="http://localhost:9318/DACStatus_Services/BusinessProcesses/StatusandAddressRetrievalService/DACStatusService.serviceagent/StatusandAddressRetrievalPortEndpoint"/>
</wsdl:port>
</wsdl:service>
<wsdl:portType name="StatusandAddressRetrievalPort">
<wsdl:operation name="StatusRetrieval">
<wsdl:input message="tns:StatusIn"/>
<wsdl:output message="tns:StatusOut"/>
<wsdl:fault name="fault1" message="tns:Fault"/>
</wsdl:operation>
<wsdl:operation name="AddressRetrieval">
<wsdl:input message="tns:AddressInfoIn"/>
<wsdl:output message="tns:AddressInfoOut"/>
<wsdl:fault name="fault1" message="tns:Fault"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="StatusandAddressRetrievalPortEndpoint1Binding" type="tns:StatusandAddressRetrievalPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="StatusRetrieval">
<soap:operation style="document" soapAction="/DACStatus_Services/BusinessProcesses/StatusandAddressRetrievalService/DACStatusService.serviceagent/StatusandAddressRetrievalPortEndpoint/StatusRetrieval"/>
<wsdl:input>
<soap:body use="literal" parts="Input"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal" parts="Output"/>
</wsdl:output>
<wsdl:fault name="fault1">
<soap:fault use="literal" name="fault1"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="AddressRetrieval">
<soap:operation style="document" soapAction="/DACStatus_Services/BusinessProcesses/StatusandAddressRetrievalService/DACStatusService.serviceagent/StatusandAddressRetrievalPortEndpoint/AddressRetrieval"/>
<wsdl:input>
<soap:body use="literal" parts="Input"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal" parts="Output"/>
</wsdl:output>
<wsdl:fault name="fault1">
<soap:fault use="literal" name="fault1"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:message name="StatusIn">
<wsdl:part name="Input" element="ns0:StatusRequest"/>
</wsdl:message>
<wsdl:message name="StatusOut">
<wsdl:part name="Output" element="ns0:StatusResponse"/>
</wsdl:message>
<wsdl:message name="Fault">
<wsdl:part name="Fault" element="ns1:fault"/>
</wsdl:message>
<wsdl:message name="AddressInfoIn">
<wsdl:part name="Input" element="ns2:AddressInfoRequest"/>
</wsdl:message>
<wsdl:message name="AddressInfoOut">
<wsdl:part name="Output" element="ns2:AddressInfoResponse"/>
</wsdl:message>
</wsdl:definitions>
有人可以帮助我吗
答案 0 :(得分:0)
共享响应中AddressInfoResponse
的命名空间符合WSDL,但unmarshaller并不期望AddressInfoResponse
元素位于命名空间http://www.carefirst.com/Enterprise/DAC/AddressRetrievalSchema中。
这意味着unmarshaller试图解组的java对象中的命名空间不正确或为空。请检查soap客户端中AddressInfoResponse
对象的命名空间。如果您已自动生成对象,则需要检查package-info
类。如果您使用SAAJ手动创建了客户端,那么您可能错过了此元素的命名空间。