Reputation: 133
I'm trying to create Jax-ws WebServices. But stuck with this behaviour of JAX-WS 2.2.
I wrote the SEI class in the following way
@WebService
@SOAPBinding(parameterStyle=ParameterStyle.WRAPPED,use=Use.LITERAL,style=Style.DOCUMENT)
public class WebServicesServlet{
@WebMethod
public GetServerTimeProperty getServerTimeProperties(){
return new GetServerTimeProperty();
}
}
The generated wsdl for the above SEI is as follows:
<types>
<xsd:schema>
<xsd:import namespace="http://soapCl.test/" schemaLocation="WebServicesService_schema1.xsd"/>
</xsd:schema>
</types>
<message name="getServerTimeProperties">
<part name="parameters" element="tns:getServerTimeProperties"> </part>
</message>
<message name="getServerTimePropertiesResponse">
<part name="parameters" element="tns:getServerTimePropertiesResponse"> </part>
</message>
And the XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapCl.test/" version="1.0" targetNamespace="http://soapCl.test/">
<xs:element name="getTimeProperties" type="tns:getServerTimeProperties"/>
<xs:element name="getTimePropertiesResponse" type="tns:getServerTimePropertiesResponse"/>
<xs:complexType name="getServerTimeProperties">
<xs:sequence/>
</xs:complexType>
**<xs:complexType name="getServerTimePropertiesResponse">**
<xs:sequence>
**<xs:element name="return" type="tns:getServerTimeProperty" minOccurs="0"/>**
</xs:sequence>
</xs:complexType>
<xs:complexType name="getServerTimeProperty">
<xs:sequence>
<xs:element name="dayLightSavingHours" type="xs:int"/>
<xs:element name="observesDayLightSavings" type="xs:boolean"/>
<xs:element name="timeZoneDisplayName" type="xs:string"/>
<xs:element name="timeZoneId" type="xs:string"/>
<xs:element name="timeZoneValue" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
SOAP Response :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<dlwmin:getServerTimePropertiesResponse xmlns:dlwmin="http://soapCl.test/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<GetServerTimeProperty>
<dayLightSavingHours>0</dayLightSavingHours>
<observesDayLightSavings>false</observesDayLightSavings>
</GetServerTimeProperty>
</dlwmin:getServerTimePropertiesResponse>
</soapenv:Body>
</soapenv:Envelope>
I've tried to generate stubs using wsimport and this is what I could observe in the generated port class
@WebMethod
**@WebResult(targetNamespace = "")**
@RequestWrapper(localName = "getServerTimeProperties", targetNamespace = "http://soapCl.test/", className = "soapCl.test.GetServerTimeProperties")
@ResponseWrapper(localName = "getServerTimePropertiesResponse", targetNamespace = "http://soapCl.test/", className = "soapCl.test.GetServerTimePropertiesResponse")
@Action(input = "http://soapCl.test/WsSessionEJBEndPoint/getServerTimePropertiesRequest", output = "http://soapCl.test/WsSessionEJBEndPoint/getServerTimePropertiesResponse")
public GetServerTimeProperty getServerTimeProperties();
I'm curious to Know why is the WebResult name different in wsdl as "return" and in soap Response as "GetServerTimeProperty" and in generated stub as "".
Also If I dont annotate the Webmethod with @WebResult(name="GetServerTimeProperty"), my stub-generated client response is null.
If I annotate my webmethod with @WebResult(name="GetServerTimeProperty"), my soapResponse is looking as follows:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns2:getServerTimePropertiesResponse xmlns:ns2="http://soapCl.test/">
<return>
<dayLightSavingHours>0</dayLightSavingHours>
<observesDayLightSavings>false</observesDayLightSavings>
</return>
</ns2:getServerTimePropertiesResponse>
</soapenv:Body>
</soapenv:Envelope>
Is @WebResult(name) is mandatory in jax-ws? I'm curios to Know how this webresult annotation is making a difference in soap response and client response.
Is is that the name should be unique for every "operationName"+"Respone" element ? My wsdl has many elements with same name as
Please Suggest on this why the WebResult name returning soap response as null if we dont annotate
Upvotes: 0
Views: 3172
Reputation: 133
I Further ruled out this
1.When two webmethods methods have same @WebResult(name="A"), the soapResponse result name differs for two methods when I mention
<wsdl-file>web-inf/wsdl/WebService.wsdl</wsdl-file>
explicitly in webservices.xml.
2.The SoapResponse return name is same when I remove the <wsdl-file>
entry in webservices.xml. Not sure how wsdl-file tag is making the difference.
Upvotes: 0