Please go to the website http://ws.apache.org/axis/java/user-guide.html and
search for
                                                                            
                                                                            
   Service Styles - RPC, Document, Wrapped, and Message                     
                                                                            
                                                                            

and use the explanation given for the message style.

Thanks,
Hrishikesh.



                                                                           
             "Rajendra"                                                    
             <[EMAIL PROTECTED]                                             
             t.com>                                                     To 
                                       <[EMAIL PROTECTED]>           
             08/24/2004 09:44                                           cc 
             AM                                                            
                                                                   Subject 
                                       need urgent help                    
             Please respond to                                             
             [EMAIL PROTECTED]                                             
                  he.org                                                   
                                                                           
                                                                           
                                                                           





Hi All,
 Im using message style. Im able to get the request from the xml file which
im passing from client.
 Now I want to send the response back to client.
 Can some give some pointers on how to add response into the SOAP Body
so that I can pass the my own xml or modified xml back to the client.


 Follows the web service method that is receiving request from the client
and suppose to send back the response.It's sending back the simple response
as follows. Now I trying to add my xml into the response body but without
any success.

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
xmln
s:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSc
hema-instance">
 <soapenv:Body><ns1:response
xmlns:ns1="http://localhost:8080/axis/services/anyt
hingGoes"/> </soapenv:Body>
</soapenv:Envelope>


 public Document method(Document request) throws
ParserConfigurationException {
    System.out.println("Document Updated = "+request.toString());


             Document response = newDocument();

             Element elem = response.createElementNS(namespace,
"response");
             response.appendChild(elem);

      I im trying to attach my xml somewhere here and send it back to the
client.

             System.out.println("Here comes  the
Request=="+getSOAPRequestText(request));
  }
    return response;
  }

  private Document newDocument() throws ParserConfigurationException {
    DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder =
documentBuilderFactory.newDocumentBuilder();
    return documentBuilder.newDocument();
  }

  public String getSOAPRequestText (Document doc) {
             StringBuffer XMLText = new StringBuffer();
             XMLText.append("<?xml version=\"1.0\" encoding=\"UTF-8\"
?>\r\n");
             Element e = doc.getDocumentElement();
             XMLText.append(getElementAsText(e));
             return XMLText.toString();
    }


    private StringBuffer getElementAsText(Element element) {
        StringBuffer elementText = new StringBuffer();
        if (element == null)
            return elementText;

        //Author name of the element.
        elementText.append("<"+element.getTagName());

        //Author attributes.
        NamedNodeMap attributes = element.getAttributes();
        int attCount = attributes.getLength();
        for (int j = 0; j<attCount; j++) {
            elementText.append(" "+attributes.item(j).getNodeName()+"=\"");
            elementText.append(attributes.item(j).getNodeValue()+"\"");
        }//for

        // Author the namespace node.
        if (element.getNamespaceURI()!=null) {
            elementText.append(" ");
            elementText.append("xmlns");
            if (element.getPrefix()!=null) {
                elementText.append(":");
                elementText.append(element.getPrefix());
            }//if
            elementText.append("=\"");
            elementText.append(element.getNamespaceURI());
            elementText.append("\" ");
        }

        elementText.append(">");

        //Author child nodes.
        for (int i=0;i<element.getChildNodes().getLength();i++) {
            Node child = element.getChildNodes().item(i);
            if (child.getNodeType() == Node.ELEMENT_NODE)
elementText.append(getElementAsText((Element)child));
            if (child.getNodeType() == Node.TEXT_NODE)
elementText.append(child.getNodeValue());
            // Process other types of child nodes if required.
        }//for

        elementText.append("</"+element.getTagName()+">");
        return elementText;
    }//getElementAsText



 Thanks in advance,
 Rajendra.


*********************************************************
Disclaimer:

This message (including any attachments) contains
confidential information intended for a specific
individual and purpose, and is protected by law.
If you are not the intended recipient, you should
delete this message and are hereby notified that
any disclosure, copying, or distribution of this
message, or the taking of any action based on it,
is strictly prohibited.

*********************************************************
Visit us at http://www.mahindrabt.com





Reply via email to