java variables need to have the same name like in SOAP request?

hi guys. i have soap service in java spring. i have this dto class:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"userid",
"trans_id"
})
@XmlRootElement(name = "idCheckRequest", namespace = "http://mycompany.lt/soap-web-service")
@Data
public class PerlasCheckIdRequestDTO {
@NotNull(message = "userId cant be null")
@Size(max = 32, message = "userId too long")
@XmlElement(name = "userid", required = true, namespace = "http://mycompany.lt/soap-web-service" )
private String userId;

@NotNull(message = "transactionId cant be null")
@Size(max = 100, message = "transactionId too long")
@XmlElement(name = "trans_id", required = true, namespace = "http://mycompany.lt/soap-web-service")
private String transactionId;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"userid",
"trans_id"
})
@XmlRootElement(name = "idCheckRequest", namespace = "http://mycompany.lt/soap-web-service")
@Data
public class PerlasCheckIdRequestDTO {
@NotNull(message = "userId cant be null")
@Size(max = 32, message = "userId too long")
@XmlElement(name = "userid", required = true, namespace = "http://mycompany.lt/soap-web-service" )
private String userId;

@NotNull(message = "transactionId cant be null")
@Size(max = 100, message = "transactionId too long")
@XmlElement(name = "trans_id", required = true, namespace = "http://mycompany.lt/soap-web-service")
private String transactionId;
}
i send this request body:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<soap:idcheck>
<soap:trans_id>903</soap:trans_id>
<soap:userid>903</soap:userid>
</soap:idcheck>
</soapenv:Body>
</soapenv:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<soap:idcheck>
<soap:trans_id>903</soap:trans_id>
<soap:userid>903</soap:userid>
</soap:idcheck>
</soapenv:Body>
</soapenv:Envelope>
but i get:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring xml:lang="en">4 counts of IllegalAnnotationExceptions</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring xml:lang="en">4 counts of IllegalAnnotationExceptions</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
i noticed that if i name my java vars the same like they are named in request xml, everything is fine. But the thing is that my code gets messy. Is there a fix for this scenario?
1 Reply
JavaBot
JavaBot2mo ago
This post has been reserved for your question.
Hey @Fragmented friends! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here. 💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server