肥皂请求对象为null-spring ws

时间:2019-06-12 12:20:26

标签: soap soapui axis spring-ws

从soap UI尝试时,即使我在req对象中发送值,我也会在请求对象中获取空值。这是什么原因?请帮助

下面是我的终点

     @Endpoint
        public class SummaryEndPoint {

            @PayloadRoot(namespace = "http://online.mysite.no", localPart ="getSummary")
            public @ResponsePayload JAXBElement<EInvoicesObjects> getSummary(@RequestPayload SummaryObject summaryObject) {


//Here summaryObject.getzDocId() returns null.
    return null;

                }
            }

肥皂请求

<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.no">
   <soapenv:Header/>
   <soapenv:Body>
      <onl:getSummary soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <in0 xsi:type="onl:SummaryObject">
            <ZDocId xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">asdasdsa</ZDocId>
            <amountDue xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">sadadsadsa</amountDue>            
         </in0>
      </onl:getSummary>
   </soapenv:Body>
</soapenv:Envelope>

请求有效载荷对象:

package com.nets.online2adapter.endpoints;

import javax.xml.bind.annotation.*;


import org.xmlsoap.schemas.soap.encoding.String;




@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SummaryObject", propOrder = {
        "zDocId",
        "amountDue"
},namespace="http://online.mysite.no")
public class SummaryObject {

    @XmlElement(name = "ZDocId", required = true, nillable = true)
    protected String zDocId;
    @XmlElement(required = true, nillable = true)
    protected String amountDue;


    /**
     * Gets the value of the zDocId property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getZDocId() {
        return zDocId;
    }

    /**
     * Sets the value of the zDocId property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setZDocId(String value) {
        this.zDocId = value;
    }

    /**
     * Gets the value of the amountDue property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getAmountDue() {
        return amountDue;
    }

    /**
     * Sets the value of the amountDue property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setAmountDue(String value) {
        this.amountDue = value;
    }

}

2 个答案:

答案 0 :(得分:0)

您的请求类名称中应带有“ request”。 请重命名您的请求类,然后​​尝试使用“ SummaryObjectRequest”。

答案 1 :(得分:0)

我遇到了同样的问题。在深入分析我的代码后,我发现这是因为命名空间。 (请参阅 https://www.baeldung.com/spring-boot-soap-web-service 处的示例)。 在您的示例中,参数 <ZDocID> and <amountDue> 应该包含在其父级的命名空间中,例如:<onl:ZDocId> and <onl:amountDue>