将axis soap webservice迁移到spring ws-RequestPayload对象,该对象值在端点方法中为null

将axis soap webservice迁移到spring ws-RequestPayload对象,该对象值在端点方法中为null,soap,wsdl,soapui,axis,spring-ws,Soap,Wsdl,Soapui,Axis,Spring Ws,使用使用AXIS生成的旧wsdl文件,使其与springws一起工作。在做了一些调整之后,我可以使用旧的wsdl生成java源代码 现在我试图从soapui发出请求,但请求值在端点方法中显示为null。请求正确地进入后端,但不是值 WSDL文件 <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:s

使用使用
AXIS
生成的旧
wsdl文件
,使其与springws一起工作。在做了一些调整之后,我可以使用旧的wsdl生成java源代码

现在我试图从
soapui
发出请求,但请求值在
端点
方法中显示为null。请求正确地进入
后端
,但不是

WSDL文件

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:onl="http://online.mysite.com">
   <soapenv:Header/>
   <soapenv:Body>
      <onl:getSummary soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <in0 xsi:type="onl:SummaryObject">
            <docid xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">doc123</docid>
            <amount xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</amount>
            <duenew xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</duenew>
            <reference xsi:type="xsd:long">?</reference>
            <sortBy xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</sortBy>
            <startDate xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</startDate>
         </in0>
      </onl:getSummary>
   </soapenv:Body>
</soapenv:Envelope>

doc123
?
?
?
?
?
Soap请求:

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:onl="http://online.mysite.com">
   <soapenv:Header/>
   <soapenv:Body>
      <onl:getSummary soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <in0 xsi:type="onl:SummaryObject">
            <docid xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">doc123</docid>
            <amount xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</amount>
            <duenew xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</duenew>
            <reference xsi:type="xsd:long">121212121</reference>
            <sortBy xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</sortBy>
            <startDate xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</startDate>
            <visibility xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</visibility>
         </in0>
      </onl:getSummary>
   </soapenv:Body>
</soapenv:Envelope>

doc123
?
?
121212121
?
?
?
端点方法:

@PayloadRoot(namespace = NAMESPACE_URI, localPart ="getSummary")
    @ResponsePayload
    public JAXBElement<EObjects> getSummary(@RequestPayload SummaryObject summaryObject) {

            System.out.println("Am done with this"+summaryObject.getDocId());
        ObjectFactory factory = new ObjectFactory();
        EObjects objects = factory.createEObjects();
        QName qname = new QName("http://online.mysite.com", "eobjects");
        return new JAXBElement(qname, EObjects.class, objects);

    }
@PayloadRoot(namespace=namespace\u URI,localPart=“getSummary”)
@回应书
公共JAXBElement getSummary(@RequestPayload SummaryObject SummaryObject){
System.out.println(“处理完这个”+summaryObject.getDocId());
ObjectFactory=新的ObjectFactory();
EObjects objects=factory.createEObjects();
QName QName=新的QName(“http://online.mysite.com“,“对象”);
返回新的JAXBElement(qname、EObjects.class、objects);
}

spring ws或CXF不再支持在轴1中生成的WSDL。这样,从WSDL生成的java类就不会有
spring
中的
JAXB
请求的
unmarshell
所需的信息。因此,
request
对象将显示为
null

我做了一件有两件事要做的工作

  • 在从WSDL生成的请求对象类的顶部添加xml根元素注释 @XmlRootElement(name=“getSomething”,名称空间= “”)

  • 手动解组请求对象,如下所示:
  • 代码

    SoapMessage message=(SoapMessage)messageContext.getRequest();
    ByteArrayOutputStream out=新建ByteArrayOutputStream();
    消息写入(输出);
    String strMsg=新字符串(out.toByteArray());DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder db=dbf.newDocumentBuilder();
    文档d=db.parse(新的InputSource(新的StringReader(strMsg));
    节点getrequestObject=d.getElementsByTagName(“yourtag”).item(0);
    JAXBContext jc=JAXBContext.newInstance(MyRequestObject.class);
    Unmarshaller Unmarshaller=jc.createUnmarshaller();
    JAXBElement je=unmarshaller.unmarshal(新)
    DOMSource(getrequestObject),MyRequestObject.class);
    
    SoapMessage message = (SoapMessage) messageContext.getRequest();
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                message.writeTo(out);
                String strMsg = new String(out.toByteArray());  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                dbf.setNamespaceAware(true);
                DocumentBuilder db = dbf.newDocumentBuilder();
                Document d = db.parse(new InputSource(new StringReader(strMsg)));
     Node getrequestObject = d.getElementsByTagName("yourtag").item(0);
    
    JAXBContext jc = JAXBContext.newInstance(MyRequestObject.class);
        Unmarshaller unmarshaller = jc.createUnmarshaller();
        JAXBElement<SummaryObject> je = unmarshaller.unmarshal(new
    DOMSource(getrequestObject), MyRequestObject.class);