You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Mohammed Burhanuddin <Mo...@xoriant.com> on 2003/04/19 08:55:01 UTC

First Timer

Hello to all,
 I am using the Webservices for the first time in my project. My requirement
is to to pass on the datasets to the the specific Webservice for processing.

 To start with, I have created  a simple HelloWorld sample Webservice using
Microsoft's Visual Studio which will return hello + the parameter passed.
When I tried to consume this method using axis at client, my parameter is
not reaching to it. Instead of my parameter string, null value is being
passed, since when I ran the client, its simply sending hello, with out the
passed parameter. I am simply unable to sort out what and where it went
wrong. I am using the sample client program at client side.
Please help me solve this problem. my client program is as follows.
 thanks in advance,
burhan.

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;

import javax.xml.rpc.ParameterMode;


public class TestClient {

	public static void main(String [] args) {

		try {

            String endpoint =
"http://10.21.0.22/aprove/Communication/Sample.asmx";

            Service  service = new Service();
       		Call     call    = (Call) service.createCall();

            call.setTargetEndpointAddress( new java.net.URL(endpoint) );
            call.setOperationName(new QName("http://tempuri.org/",
"HelloWorld"));
            call.setUseSOAPAction(true);
	
call.setSOAPActionURI("http://tempuri.org/HelloWorld");

			call.addParameter("name", XMLType.XSD_STRING,
ParameterMode.IN);
			call.setReturnType(XMLType.XSD_STRING);

			try {

				  String name = "Burhan";
				  String ret = (String) call.invoke	(new
Object[] { name });
				  System.out.println(ret);
			}
			catch (java.rmi.RemoteException re)	{
				System.out.println("Error - " + re);
			}

         } catch (Exception e) {
             e.printStackTrace();
         }

     }
}