You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by "Dilova, Tereza (BG)" <Di...@semantec.bg> on 2001/11/08 07:50:49 UTC

Problem with apache soap API

Hi to all !

I am writing simple test java client, that send soap query to exesting web
service .

package package2;
import org.apache.soap.Constants;
import org.apache.soap.Fault;
import org.apache.soap.SOAPException;
import org.apache.soap.rpc.Call;
import org.apache.soap.rpc.Parameter;
import org.apache.soap.rpc.Response;
import java.net.URL;
import org.w3c.dom.Element;
import java.util.Vector;
/**
 * Generated by the Oracle JDeveloper Web Services Proxy Generator.
 * A Web Service which displays the current local time of any city around
the world.
 */

public class zip
{
  private static final String endpoint =
"http://services.xmethods.net:80/soap/servlet/rpcrouter";
  

  
  public static Element getZip(Element parameters) throws Exception
  {

  
    Element returnVal = null;

    URL endpointURL = new URL(endpoint);
    Call call = new Call();
    call.setTargetObjectURI("");
    call.setMethodName("getTemp");    

    call.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);
    Vector params = new Vector();

    params.addElement(new Parameter("parameters", Element.class, parameters,
Constants.NS_URI_LITERAL_XML));
    call.setParams(params);
    
    Response response = call.invoke(endpointURL, ""); 
    
    System.out.println("response");
    Response response = call.invoke(endpointURL, "urn:getTemp");
    if (!response.generatedFault())
    {
      Parameter result = response.getReturnValue();
      returnVal = (Element)result.getValue();
    }
    else
    {
      Fault fault = response.getFault();
      throw new SOAPException(fault.getFaultCode(), fault.getFaultString());
    }

    return returnVal;
  }
}

And other class  with only one main method.
package package2;

import oracle.soap.util.xml.XmlUtils;
import java.io.*;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.NamedNodeMap;
import java.util.*;
import java.net.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.apache.soap.*;
import org.apache.soap.encoding.*;
import org.apache.soap.messaging.*;
import org.apache.soap.transport.SOAPTransport;
import org.apache.soap.util.xml.XMLParserUtils;
import org.apache.xerces.parsers.DOMParser;



public class t 
{
   public static void main (String[] args ) {
    try {     
      
      DOMParser parser = new DOMParser();
      parser.parse("c:\\soap.xml");
      Document doc = parser.getDocument();    
      if (doc == null) throw new Exception("Empty Request");
     
      Element params = doc.getDocumentElement();
      Element e = zip.getZip(params);
    }
    catch (Exception e) {
          System.out.println(e.toString());          
    }
   }
}

The result is Exception in thread main
java.lang.NoSuchMethodError: boolean
javax.xml.parsers.DocumentBuilderFactory.isIgnoringElementContentWhitespace(
) 	void
org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(javax.xml.parsers.Document
BuilderFactory, java.util.Hashtable) 	javax.xml.parsers.DocumentBuilder
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder()
org.w3c.dom.Document oracle.soap.util.xml.XmlUtils.parseXml(java.io.Reader) 
	org.apache.soap.rpc.Response
org.apache.soap.rpc.Call.invoke(java.net.URL, java.lang.String) 
	org.w3c.dom.Element package2.zip.getZip	(org.w3c.dom.Element) 
	void package2.t.main(java.lang.String[]) 
Process exited with exit code 1.


Can you help me ?
I see in  log , that method invoke parses response .
When I do not use apache soap api it works and result is.

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<ns1:getTempResponse xmlns:ns1="urn:xmethods-Temperature"
SOAP-ENV:encodingStyle
="http://schemas.xmlsoap.org/soap/encoding/">
<return xsi:type="xsd:float">56.0</return>
</ns1:getTempResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Thank you in advance Tereza