wsimportを使用してクライアントを生成するサードパーティのWebサービスがあります。 Webサービスへの各呼び出しは正常に完了しましたが、返される応答オブジェクトはすべてのフィールドがnullに設定されています。ネットワークの監視私は、応答メッセージのXML要素のすべてに値が入っているので、オブジェクトにnull以外のデータが含まれていることがわかります。また、old1で生成され、同じデータで呼び出された同じサービスのクライアントは、空ではない応答を返します。何が起きているのか? (それが何か違いがある場合はMOXyのJAXB実装を使用しています)。私のjax-ws webserviceクライアントは空のオブジェクトだけを返します
更新:私はそれを絞り込むことができました。 wsdlは、独自の名前空間、たとえばhttp://www.acme.com/ws
にオブジェクトを定義します。私はサービスから取得応答が
<?xml version="1.0" encoding="UTF-8"?>
... SOAP envelope ...
<ns1:opINFOWLResponse xmlns:ns1="http://www.acme.com/ws"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns1:responseINFOWL xsi:type="ns1:responseINFOWL">
<result>6003</result>
<ndserr/>
<transid>61437594</transid>
<descriptionerr>BLAH.</descriptionerr>
</ns1:responseINFOWL>
</ns1:opINFOWLResponse>
... SOAP closing tags ...
で、nullに設定されているすべてのフィールドがnull以外responseINFOWL
オブジェクトをラップするnull以外OpINFOWLResponse
に非整列化です。ちょうど楽しみのために私は
(SOAPのオーバーヘッドを除去した後に)上記のスニペットを非整列化するために数行を書く
JAXBContext ctx = JAXBContext.newInstance(OpINFOWLResponse.class);
Unmarshaller u = ctx.createUnmarshaller();
OpINFOWLResponse o = (OpINFOWLResponse) u.unmarshal(new StringReader(theSnippetAbove));
ResponseINFOWL w = o.getResponseINFOWL();
を試みたと私は同じ結果を得ます。上記のXMLを
に変更した場合
<?xml version="1.0" encoding="UTF-8"?>
<ns1:opINFOWLResponse xmlns:ns1="http://www.acme.com/ws"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns1:responseINFOWL xsi:type="ns1:responseINFOWL">
<ns1:result>6003</ns1:result>
<ns1:ndserr/>
<ns1:transid>61437594</ns1:transid>
<ns1:descriptionerr>BLAH.</ns1:descriptionerr>
</ns1:responseINFOWL>
</ns1:opINFOWLResponse>
すべて動作します。バマー。
更新(再):jaxb-RIとMoxyの両方で同じ動作です。何が間違っているのかまだ分かりません。
更新(9月9日):名前空間の資格が間違っていることについて、以下の提案は面白いですが、私はwsimportのは、物事が右になるだろうと思わ。とにかく、これは私のpackage-info.java
@XmlSchema(
namespace = "http://www.acme.com/ws",
elementFormDefault = XmlNsForm.QUALIFIED)
package it.sky.guidaTv.service.remote;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.XmlNsForm;
であり、これは私がpackage-info
で名前空間が、まだありません喜びで少し遊んでみましたResponseINFOWL
クラス
/*
* <p>Java class for responseINFOWL complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="responseINFOWL">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="result" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="descriptionerr" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="transid" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="ndserr" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="wallet" type="{http://www.acme.com/ws}t_wallet" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "responseINFOWL", propOrder = {
"result", "descriptionerr", "transid", "ndserr", "wallet" })
public class ResponseINFOWL {
@XmlElement(required = true)
protected String result;
@XmlElement(required = true)
protected String descriptionerr;
@XmlElement(required = true)
protected String transid;
protected String ndserr;
protected TWallet wallet;
// getters, setters and all.
}
の関連する部分です。
メッセージとクラスのサンプルを提供できますか?これは、マッピングの不一致がどこにあるかを判断するのに役立ちます。 –
私は適切に匿名化されたwsdlファイルとテストクラスを投稿することができました。私の場合はwsimportによって生成されます。面白いことは、同じサードパーティの他のサービスがうまく動作することです。 – agnul