Reputation: 3796
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;
}
}
Upvotes: 3
Views: 3657
Reputation: 1
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.
Upvotes: 0
Reputation: 31
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>
.
Upvotes: 1
Reputation: 1
Your request class should have 'request' in the name. Please rename your request class and try with 'SummaryObjectRequest'.
Upvotes: 0