I've been playing around with web services using jbossws-cxf. I don't think the issue is with the implementation I'm using but instead how the code is generated. Here is my pojo with the annotations for a web service.
package com.matt.test.ws;
import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
public class JbossWSTestImpl {
private String[] statuses = {"Hello","JbossWS is cool","GoodBye","l33t hax0rz"};
@WebMethod
@WebResult(name="status")
public String getStatus(){
return statuses[new java.util.Random().nextInt(3)];
}
}
My soap response when i test the webservice (with soapUI) is
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:getStatusResponse xmlns:ns2="http://ws.test.matt.com/">
<status>Hello</status>
</ns2:getStatusResponse>
</soap:Body>
</soap:Envelope>
Is there a way short of manually editing the wsdl file to modify the namespace that "ns2" is so that I can wrap the response in different tags. What I want is something like
<soap:Envelope ...>
<soap:Body>
<MyWSResponse xmlns="http://ws.test.matt.com/">
<status>Hello</status>
</MyWSResponse>
<soap:Body>
<soap:Envelope>
Are there annotations that I'm not using that can modify that? I haven't found a way to modify the wsdl that way with them as of yet.
UPDATE: changing @WebService
to @WebService(targetNamespace="http://MyWSResponse")
changed the soap request to the correct tag but the soap response message still uses ns2 instead of MyWSResponse.
You must add a new attribute
to the WebService
annotation as:
@WebService(targetNamespace="http://ws.test.matt.com/")
if you don't specify any targetNamespace
the package
will be used.