3

While trying from soap UI, Iam getting null values in request object even when I send values in req object. what would be the reason? Please help

Below is my endpoint

     @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;

                }
            }

Soap request:

<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>

Request Payload Object:

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;
    }

}
Vipin CP
  • 3,642
  • 3
  • 33
  • 55
  • How did you test this? I'd recommend setting up an integration test for your endpoint as they usually provide more insight into the inner workings of your application and look for any pointers there. [This guide](https://memorynotfound.com/spring-ws-server-side-integration-testing/) should help you with that. – Mike Floyd Jul 19 '19 at 07:48
  • Were you able to resolve this? I'm running into the same issue. In my EndPoint class, methods that have a Request Payload of String, work fine when called from SOAPUI. But in the same class, a method that has a Request Payload of a custom class, is coming in with null values. And it is named customerStatusRequest. I've posted it in this page too: https://stackoverflow.com/a/58452826/1456612 – Shahriar Oct 18 '19 at 16:06

3 Answers3

1

I had the same issue. After deep analysing my code I found that it's because namespaces. (See the example at https://www.baeldung.com/spring-boot-soap-web-service). In your example, the parameters <ZDocID> and <amountDue> should have been included in their parent's namespace, as like: <onl:ZDocId> and <onl:amountDue>.

Davronito
  • 31
  • 4
0

Your request class should have 'request' in the name. Please rename your request class and try with 'SummaryObjectRequest'.

Kapu
  • 1
0

I know it's an old question, but I recently encountered the same issue you're facing, and perhaps my answer can help others. The object I sent in the request was received as null in the method, indicating that it was not properly parsed. What worked for me was deleting the manually created classes and generating them automatically from the XSD file using the jaxb2-maven-plugin Maven plugin. I'm not 100% sure, but I believe the problem in my case was that I had kept the Request class in a different package in the project than the one specified in the targetNamespace of the XSD file.