JAX-WS: why are nested elements in the namespace "?

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;
    }
}

, - , . .

+5
2

WSI-Basic. :

http://www.ws-i.org/profiles/basicprofile-1.1.html#Part_Accessors

4.7.20, R2735 , RPC/Literal namspace.

+3

. webservice-, JAX-WS, SOAP UI. webservice . ( -). .

SOUP UI,

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.aml.infrasofttech.biz" xmlns:dat="http://dataobject.aml.infrasofttech.biz">
   <soapenv:Header/>
   <soapenv:Body>
      <web:getCIPMatchResponse>
         <!--1 or more repetitions:-->
         <web:getCIPMatchReturn>
            <dat:countries>?</dat:countries>
            <dat:dob>?</dat:dob>
            <dat:fullName>?</dat:fullName>
            <dat:isError>?</dat:isError>
            <dat:listName>?</dat:listName>
            <dat:passport>?</dat:passport>
            <dat:percentage>?</dat:percentage>
            <dat:sdnId>?</dat:sdnId>
            <dat:sdnName>?</dat:sdnName>
         </web:getCIPMatchReturn>
      </web:getCIPMatchResponse>
   </soapenv:Body>
</soapenv:Envelope>

, .

        <countries>?</countries>
        <dob>?</dob>
        <fullName>?</fullName>
        <isError>?</isError>
        <listName>?</listName>
        <passport>?</passport>
        <percentage>?</percentage>
        <sdnId>?</sdnId>
        <sdnName>?</sdnName>

JAX-WS .

  @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SdnBean", namespace = "http://dataobject.aml.infrasofttech.biz", propOrder = {
    "countries",
    "dob",
    "fullName",
    "isError",
    "listName",
    "passport",
    "percentage",
    "sdnId",
    "sdnName"
})
public class SdnBean {

jax-ws @XmlType,

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "countries",
    "dob",
    "fullName",
    "isError",
    "listName",
    "passport",
    "percentage",
    "sdnId",
    "sdnName"
})
public class SdnBean {

.

+1

All Articles