This content has been marked as final.
Show 4 replies
-
1. Re: returning array undefined in web service
mckeno Nov 26, 2007 11:43 PM (in response to mckeno)The code looks messy, but I can't find the edit functionality in this forum ??!!?? so I did a re post....
-------------
Hi all I am having this problem, not sure whether it is related to jboss web service or the client site application:
I am writing a web service inside EJB container:@Stateless @WebService(name = "Mojo", targetNamespace = "http://myservice.com/services", serviceName = "CoolService") @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED) public class MyWebService { @WebMethod @WebResult public int[] getNumber(@WebParam(name = "userName") String sth) { int[] number = new int[3]; number[0] = 7; number[1] = 2; number[2] = 3; log.info("ARRAY METHOD CALLED " + number.length); return number; } @WebMethod @WebResult public int getNum(int param) { int result = param + 2; return result ; } }
The getNum() method works fine, but the getNumber() always return undefined result(I am calling the web service using Web Sevice Connector in Flash application). So I am wondering whether I need any specific annotation for the array returning methods? -
2. Re: returning array undefined in web service
asoldano Nov 28, 2007 5:51 AM (in response to mckeno)"mckeno" wrote:
The code looks messy, but I can't find the edit functionality in this forum ??!!?? so I did a re post....
Sorry, users are not allowed to edit any post on the forum.Hi all I am having this problem, not sure whether it is related to jboss web service or the client site application:
I am writing a web service inside EJB container:@Stateless @WebService(name = "Mojo", targetNamespace = "http://myservice.com/services", serviceName = "CoolService") @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED) public class MyWebService { @WebMethod @WebResult public int[] getNumber(@WebParam(name = "userName") String sth) { int[] number = new int[3]; number[0] = 7; number[1] = 2; number[2] = 3; log.info("ARRAY METHOD CALLED " + number.length); return number; } @WebMethod @WebResult public int getNum(int param) { int result = param + 2; return result ; } }
The getNum() method works fine, but the getNumber() always return undefined result(I am calling the web service using Web Sevice Connector in Flash application). So I am wondering whether I need any specific annotation for the array returning methods?
Please post here your configuration (version of JBoss & JBossWS) as long as the your wsdl. Did you try capturing the message being exchanged? does it contain the array's values? -
3. Re: returning array undefined in web service
mckeno Nov 28, 2007 11:02 PM (in response to mckeno)Hi Alessio,
Here are some more details:
The wsdl schema:<definitions name="MyService"targetNamespace="http://xxx/yyy/services"> <types> <xs:schema targetNamespace="http://xxx/yyy/services" version="1.0"> <xs:element name="getNumber" type="tns:getNumber"/> <xs:element name="getNumberResponse" type="tns:getNumberResponse"/> <xs:complexType name="getNumber"> <xs:sequence> <xs:element minOccurs="0" name="userName" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="getNumberResponse"> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="numbers" type="xs:int"/> </xs:sequence> </xs:complexType> </xs:schema> </types> <message name="Mojo_getNumberResponse"> <part element="tns:getNumberResponse" name="getNumberResponse"/> </message> <message name="Mojo_getNumber"> <part element="tns:getNumber" name="getNumber"/> </message> <portType name="Mojo"> <operation name="getNumber" parameterOrder="getNumber"> <input message="tns:Mojo_getNumber"/> <output message="tns:Mojo_getNumberResponse"/> </operation> </portType> <binding name="MojoBinding" type="tns:Mojo"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="getNumber"> <soap:operation soapAction=""/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </binding> <service name="MojoService"> <port binding="tns:MojoBinding" name="MojoPort"> <soap:address location="http://localhost:8080/myService/MyWebService"/> </port> </service> </definitions>
The web service class in EJB container@Stateless @WebService(name = "Mojo", targetNamespace = "http://xxx/yyy/services", serviceName = "MyService") @WebContext(contextRoot="/myService") @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED) public class MyWebService { @SuppressWarnings("unused") private Logger log = Logger.getLogger(this.getClass()); @WebMethod @WebResult(name = "numbers") public int[] getNumber(@WebParam(name = "userName") String sth) { int[] number = new int[3]; number[0] = 7; number[1] = 2; number[2] = 3; System.out.println("Get Number call"); log.info("ARRAY METHOD CALLED " + number.length); return number; } }
JBoss version : [Server] Release ID: JBoss [Trinity] 4.2.0.GA (build: SVNTag=JBoss_4_2_0_GA date=200705111440)
JbossWS: I think i used the one came with the Jboss server, not sure how to check its version...
I did use soapUI to capture the request and respone and it works ok:
request:<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://xxx/yyy/services"> <soapenv:Header/> <soapenv:Body> <ser:getNumber> <!--Optional:--> <userName>3</userName> </ser:getNumber> </soapenv:Body> </soapenv:Envelope>
response:<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Header/> <env:Body> <ns2:getNumberResponse xmlns:ns2="http://mojo.streamverse.com/services"> <numbers>7</numbers> <numbers>2</numbers> <numbers>3</numbers> </ns2:getNumberResponse> </env:Body> </env:Envelope>
Only that when it is called from the Flash application(flash 7, using WebService Connector) then the results always undefined(non array result works ok in flash). -
4. Re: returning array undefined in web service
asoldano Nov 29, 2007 4:30 AM (in response to mckeno)"mckeno" wrote:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Header/> <env:Body> <ns2:getNumberResponse xmlns:ns2="http://mojo.streamverse.com/services"> <numbers>7</numbers> <numbers>2</numbers> <numbers>3</numbers> </ns2:getNumberResponse> </env:Body> </env:Envelope>
This shows the service is running fine, you have the array's value in the response that actually goes on the wire. Thus this is an issue with you Flash application that could probably have problems parsing this kind of response.