1

次のような石鹸メッセージの応答をアンマーシャリングしています

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <SOAP-ENV:Body>
      <m:soResponse SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:m="urn:tec">
         <Error/>
         <Order>
            <Number>6</Number>
         </Order>
      </m:soResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope> 

そして、私はjaxbアノテーションを次のようにバインドしています

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "body"
    })
    @XmlRootElement(name = "Envelope")
    public class Envelope {
    @XmlElement(name = "Body", namespace = "http://schemas.xmlsoap.org/soap/envelope/", required = true)
        protected Body body;
    //......
    }

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "soResponse"
    })
    @XmlRootElement(name = "Body")
    public class Body {

        @XmlElement(namespace = "http://schemas.xmlsoap.org/soap/envelope/", required = true)
        protected soResponse;
    //-----------
    }
XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "error",
    "order"
})
@XmlRootElement(name = "soResponse")
public class soResponse{

    @XmlElement(name = "Error", required = true)
    protected soResponse.Error error;
    @XmlElement(name = "Order", required = true)
    protected soResponse.Order order;
    @XmlAttribute(name = "encodingStyle", namespace = "http://schemas.xmlsoap.org/soap/envelope/", required = true)
    @XmlSchemaType(name = "anyURI")
    protected String encodingStyle;
//-----------------------
}

問題は、私が soResponse を常に null にしているということです!!?

4

1 に答える 1

4

間違った名前空間を持っているようです

@XmlElement(namespace = "http://schemas.xmlsoap.org/soap/envelope/", required = true)
protected soResponse;

<SOAP-ENV:soResponse>これはではなくを探します<m:soResponse xmlns:m="urn:tec">

于 2012-09-14T13:40:56.000 に答える