You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Harm Verhagen <ha...@gmail.com> on 2009/12/02 12:43:43 UTC
Webservice has extra in response.
Hi,
When using CXF to construct a webservice I see that my response xml always
gets an extra wrapper layer.
It always gets an extra <return> ... </return> in the soap responses.
*
Actual soap response.*
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:deleteNetworkResponse xmlns:ns1="http://test.com/ble">
<return>
<resultCode>-514</resultCode>
<resultDescription>Not found</resultDescription>
</return>
</ns1:deleteNetworkResponse>
</soap:Body>
</soap:Envelope
*Expected response*
**
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:deleteNetworkResponse xmlns:ns1="http://test.com/ble">
<resultCode>-514</resultCode>
<resultDescription>Not found</resultDescription>
</ns1:deleteNetworkResponse>
</soap:Body>
</soap:Envelope
*java code*
@WebService( targetNamespace = "http://test.com/ble")
public interface NetworkAdmin {
...
...
@WebMethod
public generalResult deleteNetwork(
@WebParam(name = "token") String token,
@WebParam(name = "id") int id);
}
where
public class generalResult {
protected int resultCode;
protected String resultDescription;
//+ getters/setters
}
I found no way to disable this.
Adding @ResponseWrapper with no localname didn.t help -> still <return>
... </return>
Adding @ResponseWrapper(localName = "deleteNetworkResponse") didnt' help ->
still <return> ... </return>
*
*
What is going on here ?
Does anyone know how to get the expected response ?
Regards,
Harm Verhagen
Re: Webservice has extra in response.
Posted by Daniel Kulp <dk...@apache.org>.
I think the only way to do that would be to do something like:
@WebMethod
@WebResult(name = "resultCode")
public int deleteNetwork(
@WebParam(name = "token") String token,
@WebParam(name = "id") int id,
@WebParam(name = "resultDescription", mode=OUT)
Holder<String> description);
Alternatively, switch to BARE mode and do
@WebMethod
public DeleteNetworkResponse deleteNetwork(DeleteNetwork req);
with the DeleteNetworkResponse/DeleteNetwork being beans that would wrapper
the appropriate in and out parts.
Dan
On Wed December 2 2009 6:43:43 am Harm Verhagen wrote:
> Hi,
>
> When using CXF to construct a webservice I see that my response xml always
> gets an extra wrapper layer.
> It always gets an extra <return> ... </return> in the soap responses.
>
> *
>
>
> Actual soap response.*
>
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
> <ns1:deleteNetworkResponse xmlns:ns1="http://test.com/ble">
> <return>
> <resultCode>-514</resultCode>
> <resultDescription>Not found</resultDescription>
> </return>
> </ns1:deleteNetworkResponse>
> </soap:Body>
> </soap:Envelope
>
>
> *Expected response*
> **
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
> <ns1:deleteNetworkResponse xmlns:ns1="http://test.com/ble">
> <resultCode>-514</resultCode>
> <resultDescription>Not found</resultDescription>
> </ns1:deleteNetworkResponse>
> </soap:Body>
> </soap:Envelope
>
> *java code*
>
> @WebService( targetNamespace = "http://test.com/ble")
> public interface NetworkAdmin {
>
> ...
> ...
>
> @WebMethod
> public generalResult deleteNetwork(
> @WebParam(name = "token") String token,
> @WebParam(name = "id") int id);
>
>
>
> }
>
> where
> public class generalResult {
>
> protected int resultCode;
> protected String resultDescription;
>
> //+ getters/setters
> }
>
>
> I found no way to disable this.
> Adding @ResponseWrapper with no localname didn.t help -> still <return>
> ... </return>
> Adding @ResponseWrapper(localName = "deleteNetworkResponse") didnt' help
> -> still <return> ... </return>
> *
> *
> What is going on here ?
> Does anyone know how to get the expected response ?
>
>
> Regards,
> Harm Verhagen
>
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog