axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ahmetspahic, Nermin" <Nahmetspa...@envestnetpmc.com>
Subject Soap 2.0 vs Axis Client code..please help.
Date Wed, 14 Aug 2002 16:03:01 GMT
Hi,

we are attempting to make a webservice request using an axis client.  We were succesful at
this with a Soap 2.0 Client.
Attached is our Soap 2.0 code that works, then our Axis client code that doesn't (it compiles),
then the error we get when running TestClient.  Any help would be greatly appreciated.

Nermin


Here is our Soap 2.0 client code that works:
----------------------------------------------
import java.net.*; 
import java.util.*; 
import org.apache.soap.*; // Body, Envelope, Fault, Header 
import org.apache.soap.rpc.*; // Call, Parameter, Response 
public class TestClient
   { 
   public static void main( String[] args ) throws Exception 
     { 
	 URL url = new URL( "http://www.xxx.xxx/soap/servlet/rpcrouter" ); 
	 String urn = "urn:xxxMethod"; 
	 
	Call call = new Call();
	call.setTargetObjectURI( urn ); 
	call.setMethodName("getInfo");
     	call.setEncodingStyleURI( Constants.NS_URI_SOAP_ENC ); 
    
	Vector params = new Vector( );
	params.addElement (new Parameter("param1", String.class, "134", null));
	params.addElement (new Parameter("param2", String.class, "ABC", null));
	params.addElement (new Parameter("param3", String.class, "junk", null));
	params.addElement (new Parameter("param4", String.class, "asdf", null));
	params.addElement (new Parameter("param5", String.class, "2002-07-27", null));
	params.addElement (new Parameter("param6", String.class, "ABCDEFG", null));
	params.addElement (new Parameter("param7", String.class, "", null));
	
	call.setParams( params ); 
	
	try 
       { 
       System.out.println( "invoke service\n" + "  URL= " + url + "\n  URN =" + urn ); 
       Response response = call.invoke( url, "" ); // invoke the service 
       if( !response.generatedFault() ) 
         { 
         Parameter result = response.getReturnValue(); // response was OK 
         System.out.println( "Result= " + result.getValue() ); 
         } 
       else 
         { 
         Fault f = response.getFault(); // an error occurred 
         System.err.println( "Fault= " + f.getFaultCode() + ", " + f.getFaultString() ); 
         } 
       } 
     catch( SOAPException e ) // call could not be sent properly 
       { 
       System.err.println( "SOAPException= " + e.getFaultCode() + ", " + e.getMessage() );

       } 
     } 
   }
----------------------------------------------

Here is our Axis client that we can't get to work:
----------------------------------------------

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

import javax.xml.namespace.QName;

public class TestClient
{
   public static void main(String [] args) {
       try {
		   String endpoint = "http://www.xxx.xxx/soap/servlet/rpcrouter";
     
           Service  service = new Service();
           Call     call    = (Call) service.createCall();

           call.setTargetEndpointAddress( new java.net.URL(endpoint) );
           call.setOperationName(new QName("http://soapinterop.org/", "getMethod") );

           // Call to addParameter/setReturnType as described in user-guide.html
           	call.addParameter("param1",org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
		call.addParameter("param2",org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
		call.addParameter("param3",org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
		call.addParameter("param4",org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
		call.addParameter("param5",org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
		call.addParameter("param6",org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
		call.addParameter("param7",org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
		   
		call.setReturnType(org.apache.axis.Constants.XSD_STRING);
		String ret = (String) call.invoke( new Object[] { "134","ABC","junk","asdf","2002-07-27","ABCDEFG",""
} );

           System.out.println( ret );
       } catch (Exception e) {
           System.err.println(e.toString());
       }
   }
}

Here is our error
----------------------------------------------

C:\axis-1_0>java TestClient
- Mapping Exception to AxisFault
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
 faultString: service 'http://soapinterop.org/' unknown
 faultActor: /soap/servlet/rpcrouter
 faultDetail:
        stackTrace: AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
 faultString: service 'http://soapinterop.org/' unknown
 faultActor: /soap/servlet/rpcrouter
 faultDetail:

service 'http://soapinterop.org/' unknown
        at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.
java:135)
        at org.apache.axis.encoding.DeserializationContextImpl.endElement(Deseri
alizationContextImpl.java:904)
        at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1398)
        at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLVa
lidator.java:1019)
        at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.disp
atch(XMLDocumentScanner.java:1256)
        at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentS
canner.java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:948)
        at javax.xml.parsers.SAXParser.parse(Unknown Source)
        at org.apache.axis.encoding.DeserializationContextImpl.parse(Deserializa
tionContextImpl.java:213)
        at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:457)
        at org.apache.axis.Message.getSOAPEnvelope(Message.java:362)
        at org.apache.axis.client.Call.invokeEngine(Call.java:2046)
        at org.apache.axis.client.Call.invoke(Call.java:2016)
        at org.apache.axis.client.Call.invoke(Call.java:1786)
        at org.apache.axis.client.Call.invoke(Call.java:1711)
        at org.apache.axis.client.Call.invoke(Call.java:1251)
        at TestClient.main(TestClient.java:32)


service 'http://soapinterop.org/' unknown
        at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.
java:135)
        at org.apache.axis.encoding.DeserializationContextImpl.endElement(Deseri
alizationContextImpl.java:904)
        at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1398)
        at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLVa
lidator.java:1019)
        at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.disp
atch(XMLDocumentScanner.java:1256)
        at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentS
canner.java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:948)
        at javax.xml.parsers.SAXParser.parse(Unknown Source)
        at org.apache.axis.encoding.DeserializationContextImpl.parse(Deserializa
tionContextImpl.java:213)
        at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:457)
        at org.apache.axis.Message.getSOAPEnvelope(Message.java:362)
        at org.apache.axis.client.Call.invokeEngine(Call.java:2046)
        at org.apache.axis.client.Call.invoke(Call.java:2016)
        at org.apache.axis.client.Call.invoke(Call.java:1786)
        at org.apache.axis.client.Call.invoke(Call.java:1711)
        at org.apache.axis.client.Call.invoke(Call.java:1251)
        at TestClient.main(TestClient.java:32)
service 'http://soapinterop.org/' unknown

Mime
View raw message