Great both of those content types worked. Thanks!!!
Now, I am trying to build a service that would handle JSON data. Need to receive data in JSON format and return response in JSON format. I have looked at the article referenced earlier: http://wso2.org/library/768 However, I am unclear on what aspects do I need to implement on the service side. Can I have a POJO-based service that accepts JSON and return JSON? I do see samples for JSON clients. I would appreciate if someone could point me to a JSON service example. (Not interested in SOAP-based services. REST is preferred.) Thank you very much. On 10/6/07, Upul Godage <[EMAIL PROTECTED]> wrote: > > Hi, > > I think Content-Type is not set right. > Try this, > builder.setHeader("Content-Type", "application/xml"); > before builder.sendRequest(). > > If it doesn't work try, builder.setHeader ("Content-Type", "text/xml"); > > Hope this works > > Upul > > On 10/7/07, Anas Mughal < [EMAIL PROTECTED]> wrote: > > > > I am getting errors when I try to call an Axis POJO service from a > > Google Web Toolkit application. The service I am trying to call is the > > sample service called "Version". It returns a string with the Axis version > > number. The first question I have is whether it is possible to call Axis2 > > services from non Axis2 clients. In my case, the client is an AJAX > > application built using GWT. > > > > Here is the GWT code that makes the call: > > > > public static void doGet(String url) { > > RequestBuilder builder = new RequestBuilder(RequestBuilder. > > GET, url); > > try { > > Request response = builder.sendRequest(null, new > > HTTPResponseHandler() ); > > } catch (RequestException e) { > > System.out.println("Exception caught."); > > } > > } > > > > Where url = "http://localhost:8080/axis2/services/Version/getVersion " > > > > > > If I make the request as GET request, I get the following error: > > > > <html><head><title>Apache Tomcat/6.0.14 - Error > > report</title><style><!--H1 > > {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} > > H2 > > {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} > > H3 > > {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} > > BODY > > {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B > > {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} > > P > > {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A > > {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> > > </head> > > <body><h1>HTTP Status 500 - </h1><HR size="1" > > noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> > > <u></u></p><p><b>description</b> <u>The server encountered an internal error > > () that prevented it from fulfilling this > > request.</u></p><p><b>exception</b> > > <pre>java.lang.NullPointerException > > org.apache.axis2.transport.TransportUtils.createDocumentElement( > > TransportUtils.java:156) > > org.apache.axis2.transport.TransportUtils.createSOAPMessage ( > > TransportUtils.java:111) > > org.apache.axis2.transport.http.util.RESTUtil.processURLRequest( > > RESTUtil.java:101) > > > > org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest > > (AxisServlet.java :799) > > org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java > > :242) > > javax.servlet.http.HttpServlet.service(HttpServlet.java:690) > > javax.servlet.http.HttpServlet.service(HttpServlet.java:803) > > </pre></p><p><b>note</b> <u>The full stack trace of the root cause is > > available in the Apache Tomcat/6.0.14 logs.</u></p><HR size="1" > > noshade="noshade"><h3>Apache Tomcat/6.0.14</h3></body></html> > > > > > > > > If I make the request as a POST request, I get the following error: > > > > <?xml version='1.0' encoding='utf-8'?> > > <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" > > xmlns:wsa="http://www.w3.org/2005/08/addressing "> > > <soapenv:Header><wsa:Action>http://www.w3.org/2005/08/addressing/soap/fault > > </wsa:Action></soapenv:Header> > > <soapenv:Body> > > <soapenv:Fault> > > > > <soapenv:Code><soapenv:Value>soapenv:Receiver</soapenv:Value></soapenv:Code> > > > > <soapenv:Reason><soapenv:Text xml:lang="en-US"> > > java.lang.NullPointerException</soapenv:Text></soapenv:Reason> > > <soapenv:Detail /> > > </soapenv:Fault> > > </soapenv:Body> > > </soapenv:Envelope> > > > > > > If I hit the service from my browser, I get successful response: > > > > <ns:getVersionResponse xmlns:ns=" http://axisversion.sample"> > > <ns:return>Hello I am Axis2 version service , My version is 1.3 > > </ns:return> > > </ns:getVersionResponse> > > > > > > The Axis2 service is the sample POJO service called "Version". > > > > Any help or guidance would be greatly appreciated. > > Best Regards. > > -- > > Anas Mughal > > > > > -- Anas Mughal
