wsimport를 사용하여 클라이언트를 생성하는 제 3 자 웹 서비스가 있습니다. webservice에 대한 각 호출은 성공적으로 완료되지만 반환되는 응답 객체는 모든 필드가 null로 설정됩니다. 네트워크 모니터링 나는 응답 메시지의 모든 XML 엘리먼트에 값이 있다는 것을 확인할 수있다. 따라서 객체는 null이 아닌 데이터를 가져야한다. 또한 old axis1로 생성되고 동일한 데이터로 호출 된 동일한 서비스에 대한 클라이언트는 비어 있지 않은 응답을 반환합니다. 어떤 생각인지 알 겠어? (차이가 나는 경우 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
에 정렬 화합니다. 그냥 재미를 위해 I합니다 (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와 목시와 같은 동작. 아직도 무엇이 잘못되었는지 전혀 모릅니다.
업데이트 (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가 생성했습니다. 재미있는 점은 동일한 제 3 자의 다른 서비스가 정상적으로 작동한다는 것입니다. – agnul