It looks like you might be trying to set-up a SOAP method using SOAP RPC or
SOAP document-style encoding. That is, the input is an XML tree in String
form. If that's true then the output should also be a String, even if it
contains an XML tree. Most XML libraries give you a method to output an XML
tree as a String. For example, in JDOM you would use:

DOMOutputter do = new DOMOutputter()
String myxmltree = do.output( element )

Hope this helps.

-Frank

-- 
Frank Cohen, Founder, http://www.PushToTest.com, phone: 408 374 7426

PushToTest offers free open-source test software and global services
solutions that test, monitor and automate Web Service systems for
functionality, scalability and performance.


> From: "Ghershony, Arie" <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> Date: Tue, 11 Feb 2003 15:13:46 -0500
> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
> Subject: return value as an XML document
> 
> Hi,
> Can any one tell me why do I receive the following error while compling:"
> Incompatible types found:
> org.w3c.dom.Element
> required: java.lang.String
> return result
> ^
> 
> 1 error.
> 
> This is the relevant code:
> 
> import org.apache.axis.client.Call;
> import org.apache.axis.client.Service;
> import org.apache.axis.message.SOAPEnvelope;
> import org.apache.axis.message.SOAPBodyElement;
> import org.apache.axis.utils.XMLUtils;
> 
> import org.w3c.dom.Document;
> import org.w3c.dom.Element;
> import org.w3c.dom.Node;
> import org.w3c.dom.NodeList;
> 
> ... some code here
> 
> it works when I am using command line argument:
> public static void main(String [] args) throws Exception {
> 
> but not if I pass a String array to a function:
> 
> public String getBattleService(String[] uniqb) throws Exception {
> 
> DocumentBuilderFactory documentBuilderFactory = null;
> DocumentBuilder  parser                 = null;
> 
> // We need a namespace-aware parser
> documentBuilderFactory = DocumentBuilderFactory.newInstance();
> documentBuilderFactory.setNamespaceAware(true);
> parser = documentBuilderFactory.newDocumentBuilder();
> 
> // We create the document for the request (the XML document that will
> // be embedded inside the SOAP body).
> Document document = parser.newDocument();
> Element  element  = document.getDocumentElement();
> 
> // The <portfolio/> element is the root of our document;
> Element requestElement = document.createElementNS(nameSpaceURI,
> orderbattleTag);
> // Element command        = document.createElement(args[0]);
> Element command        = document.createElement(uniqb[0]);
> requestElement.appendChild(command);
> 
> // We add the list of ticker symbols
> for(int index = 1; index < uniqb.length; index++) {
> Element ticker = document.createElement(tickerTag);
> 
> // ticker.appendChild(document.createTextNode(args[index]));
> ticker.appendChild(document.createTextNode(uniqb[index]));
> command.appendChild(ticker);
> }
> 
> // Unless the command is a get, we add the get command
> if(!uniqb.equals(getCommand)) {
> requestElement.appendChild(document.createElement(getCommand));
> }
> 
> Element result = null;
> boolean local  = false;  // set to true for local test (inproc)
> 
> if(local) {
> // Local test, no SOAP
> result = orderbattle(requestElement,
> (Element)requestElement.cloneNode(true));
> } else {
> // We create a SOAP request to submit the XML document to the
> 
> // server. You might need to replace the following URL with what
> is 
> // suitable for your environment
> "http://localhost:8080/axis/servlet/AxisServlet";;
> Service service     = new Service();
> Call    call        = (Call)service.createCall();
> 
> // Create a SOAP envelope to wrap the newly formed document
> SOAPEnvelope    requestEnvelope = new SOAPEnvelope();
> SOAPBodyElement requestBody     =
> new SOAPBodyElement(requestElement);
> requestEnvelope.addBodyElement(requestBody);
> 
> // Set the endpoint URL (address we are talking to) and method name
> call.setTargetEndpointAddress(new URL(endpointURL));
> call.setSOAPActionURI(orderbattleTag); // method name = tag name
> 
> // Submit the document to the remote server
> SOAPEnvelope responseEnvelope = call.invoke(requestEnvelope);
> 
> // Get the <orderbattle/> element from the response
> SOAPBodyElement responseBody =
> (SOAPBodyElement)responseEnvelope.getBodyElements().get(0);
> result = responseBody.getAsDOM();
> }
> return result; 
> }
> }
> 
> 
> Thanks,
> Arie

Reply via email to