【问题标题】:Soap request object comes as null - spring wsSoap 请求对象为 null - spring ws
【发布时间】:2019-10-26 23:05:23
【问题描述】:

在尝试使用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;
    }

}

【问题讨论】:

  • 你是如何测试这个的?我建议为您的端点设置一个集成测试,因为它们通常可以更深入地了解您的应用程序的内部工作,并在那里寻找任何指针。 This guide 应该可以帮助您。
  • 你能解决这个问题吗?我遇到了同样的问题。在我的 EndPoint 类中,具有字符串请求有效负载的方法在从 SOAPUI 调用时可以正常工作。但是在同一个类中,具有自定义类的请求有效负载的方法以空值传入。它被命名为customerStatusRequest。我也在这个页面上发布了它:stackoverflow.com/a/58452826/1456612

标签: soap soapui axis spring-ws


【解决方案1】:

您的请求类名称中应包含“请求”。 请重命名您的请求类并尝试使用“SummaryObjectRequest”。

【讨论】:

    【解决方案2】:

    我有同样的问题。在深入分析我的代码后,我发现这是因为命名空间。 (参见https://www.baeldung.com/spring-boot-soap-web-service 的示例)。 在您的示例中,参数 &lt;ZDocID&gt; and &lt;amountDue&gt; 应该已包含在其父名称空间中,例如:&lt;onl:ZDocId&gt; and &lt;onl:amountDue&gt;

    【讨论】:

      猜你喜欢
      • 2015-11-15
      • 1970-01-01
      • 1970-01-01
      • 2011-11-27
      • 2021-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多