Results 1 to 2 of 2
  1. #1
    Olegus is offline Member
    Join Date
    Aug 2010
    Posts
    1
    Rep Power
    0

    Question Problem to return XML structured WebMethod response

    Hello All.
    I have Java WebProject with WebService interface. (build by NetBeans, running under TomCat 6.0)
    There is method with String Output type defined in Java Wrapper.
    @WebMethod(operationName = "MyMethod")
    public String MyMethod(@WebParam(name = "STARTLAT")
    double STARTLAT, @WebParam(name = "STARTLON")
    double STARTLON, @WebParam(name = "ENDLAT")
    double ENDLAT, @WebParam(name = "ENDLON")
    double ENDLON) {
    try
    {
    MyBaseClass ts = new MyBaseClass();
    String path= ts.GetPath(STARTLAT, STARTLON, ENDLAT, ENDLON);
    return(path);
    }
    catch (Exception e) {
    return ("<Error>"+ e.getMessage()+"</Error>");
    }
    }

    Method is always returns XML formatted string, but on client side I receives it changed a little bit.:(
    Instead sent "<roadlength>0</roadlength>" string it looks like
    <ns2:MyMethodResponse xmlns:ns2="http://TrackIt.com/">
    <return>&lt;roadlength>0.0&lt;/roadlength></return>
    </ns2:MyMethod<Response>

    Sometimes response is embedded within <![CDATA[
    <return><![CDATA[<roadlength>9.6</roadlength><Segments>...</Segments>]]></return>

    What I need to specify within Java Web Service Wrapper or WSDL in order to get "fresh" XML between <return></return>, without &lt; and <![CDATA[

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default

    Then define the response type.

    At the moment it is defined as a simple string, so will escape any html characters so as not to mess up the response.

    Of course this won't work if you still simply assign some xml-based text to any of the return values. You'll have to break the data out of the xml, or manually code the response.

Similar Threads

  1. get-response problem (snmp4j)
    By easymod in forum Networking
    Replies: 1
    Last Post: 09-28-2011, 08:23 AM
  2. Replies: 0
    Last Post: 06-07-2010, 07:48 AM
  3. problem while using return statement
    By shaluchandran in forum New To Java
    Replies: 10
    Last Post: 12-12-2008, 06:29 PM
  4. Replies: 4
    Last Post: 10-02-2008, 06:32 PM
  5. response.sendRedirect problem
    By christina in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 08-03-2007, 05:23 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •