Be careful with that as you may not get the correct results What I would do is 
transform to text/plain
Here is the GWT doc

The back-end server is expected to respond with a content-type of 'text/html', 
meaning that the text returned will be treated as HTML. If any other 
content-type is specified by the server, then the result html sent in the 
onFormSubmit event will be unpredictable across browsers, and the 
FormHandler.onSubmitComplete(FormSubmitCompleteEvent) event may not fire at 
all. 

  Tip:
  The initial implementation of FormPanel specified that the server respond 
with a content-type of 'text/plain'. This has been intentionally changed to 
specify 'text/html' because 'text/plain' cannot be made to work properly on all 
browsers.

  RequestBuilder.java integrates with RPC as demonstrated here 
   /*
     * Internal method that actually sets our cached headers on the underlying
     * JavaScript XmlHttpRequest object. If there are no headers set, then we 
set
     * the "Content-Type" to "text/plain; charset=utf-8". This is really lining 
us
     * up for integration with RPC.
     */
    private void setHeaders(JavaScriptObject xmlHttpRequest)
  {
       XMLHTTPRequest.setRequestHeader(xmlHttpRequest, "Content-Type",
            "text/plain; charset=utf-8");
  }
So the solution is your server will transform your output from XML to 
text/plain and send it back to the client as text/plain or JSON so that your 
RPC plumbing will work..
Once that is working I would get your server to transform XML to HTML and send 
that back

If you are constrained to implement XMLHttpRequest with content-type=text/xml 
then look at Dojo as they
have a XSLTransform that works from the client (reference 
/tests/xml/test_XslTransform.html)..although you may have to modify your XSLs 
(full-page.xsl specifically) to properly transform and format your XML to HTML

Martin

Martin--
  ----- Original Message ----- 
  From: Upul Godage 
  To: [email protected] 
  Sent: Saturday, October 06, 2007 10:15 PM
  Subject: Re: Calling Axis2 services from GWT


  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



Reply via email to