Having a toy as below
@WebService(targetNamespace="http://www.example.org/stock")
@SOAPBinding(style=Style.RPC,parameterStyle=ParameterStyle.WRAPPED)
public class GetStockPrice {
@WebMethod(operationName="GetStockPrice",action="urn:GetStockPrice")
@WebResult(partName="Price")
public Double getPrice(
@WebParam(name="StockName")
String stock
) {
return null;
}
}
The client created by JAX-WS creates a SOAP message in which the StockName parameter has no namespace:
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:GetStockPrice xmlns:ns2="http://www.example.org/stock">
<StockName>IBM</StockName>
</ns2:GetStockPrice>
</S:Body>
</S:Envelope>
I would expect and would like StockName to be generated as
<ns2:StockName>IBM</ns2:StockName>
i.e. in the target namespace, not anonymous (ns2 is not the default as far as I can see from the message).
I wonder how to get JAX-WS to add a target namespace to nested message elements?
An attempt to specify a namespace in the WebParam annotation did not change anything, since this parameter is ignored when using RPC.
Or ... Does this mean that RPC-style options are always anonymous?
UPDATE
Stupid to me. Partially resolved. I had to do
- style = ,
- param style = ,
- WebParam ( ? , )
:
@WebService(targetNamespace="http://www.example.org/stock")
@SOAPBinding(style=Style.DOCUMENT,parameterStyle=ParameterStyle.WRAPPED)
public class GetStockPrice {
@WebMethod(operationName="GetStockPrice",action="urn:GetStockPrice")
@WebResult(partName="Price")
public Double getPrice(
@WebParam(name="StockName",targetNamespace="http://www.example.org/stock")
String stock
) {
return null;
}
}
, - , . .