2016-06-13 10 views
0

次のSOAPメッセージがあり、jaxbクラスが生成されています。SOAPメッセージはJavaオブジェクトに構文解析できません

SOAPメッセージ:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<soapenv:Body> 
<ns1:sendSmsResponse xmlns:ns1="http://www.csapi.org/schema/parlayx/sms/send/v2_2/local"> 
<result>100001200301111029065e4000141</result> 
</ns1:sendSmsResponse> 
</soapenv:Body> 
</soapenv:Envelope> 

JAXBクラス

@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "sendSmsResponse", propOrder = { 
    "result" 
}) 
public class SendSmsResponse { 
    @XmlElement(required = true) 
    protected String result; 
    public String getResult() { 
     return result; 
    } 
    public void setResult(String value) { 
     this.result = value; 
    } 

} 

しかし、次のように、これは非整列化例外を生成しました。

javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: unexpected element (uri:"http://www.csapi.org/schema/parlayx/sms/send/v2_2/local", local:"result"). Expected elements are <{}result> 
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:161) 

しかし、私は<ns1:result>からns1:を削除する場合は、それが解析されます。何が原因だろうか?

答えて

1

エラーメッセージは、名前空間を持たない結果要素(「<」内の「{}」は名前空間を持たないことを意味します)を期待している間に、名前空間を持つ結果要素が検出されたことを示します。

@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "sendSmsResponse", propOrder = { 
    "result" 
}) 
public class SendSmsResponse { 
    @XmlElement(required = true,namespace="http://www.csapi.org/schema/parlayx/sms/send/v2_2/local") 
    protected String result; 
    public String getResult() { 
     return result; 
    } 
    public void setResult(String value) { 
     this.result = value; 
    } 

} 

あなたが名前空間属性を経由してJAXBに名前空間を指定する必要があります

関連する問題