'Jax-ws two @webparam with same name and different namespace
I have re-written Jax-ws service in spring boot using Bottom-Up approach from old legacy code. I will be using two or more @webparam in the same method and will access it. My goal is maintain the Soap request and response as it is, without any change. But I'm stuck in one scenario where the @webparam name is same for two elements but different namespace. But this is giving me the error
"com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Class has two properties of the same name "xxxxxx"
Working example with different name and namespace:
Soap Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://example.com/test1/"
xmlns:ns2="http://example.com/test2/">
<soapenv:Body>
<ns1:testName1>
...some inside nodes...
</ns1:testName1>
<ns2:testName2>
...some inside nodes...
</ns2:testName2>
</soapenv:Body>
</soapenv:Envelope>
Bottom-Up-code to receive request
@Service
@WebService
@SOAPBinding
public class SoapJaxwsController {
public Object testSoapMethod(
@WebParam(name = "testName1", targetNamespace = "http://example.com/test1/") TestName1
testName1,
@WebParam(name = "testName2", targetNamespace = "http://example.com/test2/") TestName2
testName2)
{
//Here im able to receive both the request without any issues.
return new Object();//just for example
}
}
Above one is working fine and im able to map the request with corresponding classes.
Not-Working example with same name and different namespace:
Soap Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://example.com/test1/"
xmlns:ns2="http://example.com/test2/">
<soapenv:Body>
<ns1:testName>
...some inside nodes...
</ns1:testName>
<ns2:testName>
...some inside nodes...
</ns2:testName>
</soapenv:Body>
</soapenv:Envelope>
Bottom-Up-code to receive request
@Service
@WebService
@SOAPBinding
public class SoapJaxwsController {
public Object testSoapMethod(
@WebParam(name = "testName", targetNamespace = "http://example.com/test1/") TestName1
testName1,
@WebParam(name = "testName", targetNamespace = "http://example.com/test2/") TestName2
testName2)
{
//Because of this request, spring boot app is not starting
return new Object();//just for example
}
}
Above one is not working and giving the error
"com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Class has two properties of the same name "testName"
Any suggestion is much appreciated. Thanks in advance. Looking forward for answers.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
