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 Ravi Krishnamurthy <ra...@savvion.com> on 2005/06/06 07:56:38 UTC
wrapped style client
Hello:
I'm trying to write a client to document/literal webservice as wrapped
style to the following webservice:
http://chs.gotdotnet.com/quickstart/aspplus/samples/services/MathService/VB/MathService.asmx
I have attached my client program. I'm trying to invoke the Add
operation. There are 2 static methods in the program:
1. add_good - this gives the expected result (12 + 12 = 24)
2. add_bad - returns 0 - Passing the same input. Looks like I'm doing
something wrong which is not very obvious to me. Could someone throw
some pointers.
Thanks for your help and time.
Regards,
Ravi
Re: wrapped style client
Posted by Ravi Krishnamurthy <ra...@savvion.com>.
I had to make the following changes in the addParameter:
_call.addParameter(new javax.xml.namespace.QName("http://tempuri.org/",
"A"),org.apache.axis.Constants.XSD_FLOAT,float.class,ParameterMode.IN);
_call.addParameter(new javax.xml.namespace.QName("http://tempuri.org/",
"B"),org.apache.axis.Constants.XSD_FLOAT,float.class,ParameterMode.IN);
instead of
_call.addParameter(
"A",org.apache.axis.Constants.XSD_FLOAT,float.class,ParameterMode.IN);
_call.addParameter(
"B",org.apache.axis.Constants.XSD_FLOAT,float.class,ParameterMode.IN);
Dont know why I did not get any exception if that is not right!!
Thanks,
Ravi
Ravi Krishnamurthy wrote:
> Hello:
> I'm trying to write a client to document/literal webservice as wrapped
> style to the following webservice:
>
> http://chs.gotdotnet.com/quickstart/aspplus/samples/services/MathService/VB/MathService.asmx
>
>
> I have attached my client program. I'm trying to invoke the Add
> operation. There are 2 static methods in the program:
>
> 1. add_good - this gives the expected result (12 + 12 = 24)
> 2. add_bad - returns 0 - Passing the same input. Looks like I'm
> doing something wrong which is not very obvious to me. Could someone
> throw some pointers.
>
> Thanks for your help and time.
>
> Regards,
> Ravi
>
>
>------------------------------------------------------------------------
>
>import org.apache.axis.client.Call;
>import org.apache.axis.client.Service;
>import org.apache.axis.enum.Style;
>import org.w3c.dom.Document;
>import org.w3c.dom.Element;
>
>import javax.xml.namespace.QName;
>import javax.xml.rpc.ServiceFactory;
>import javax.xml.rpc.ParameterMode;
>import java.net.URL;
>
>
>import java.util.Iterator;
>
>public class MathClient
>{
> private static String endpoint = "http://chs.gotdotnet.com/quickstart/aspplus/samples/services/MathService/VB/MathService.asmx";
> private static String wsdlURL = endpoint + "?WSDL";
> public static void main(String [] args) throws Exception {
>
>
> //checkExists();
> add_good();
>
> add_bad();
> //checkExists();
>
>
>
> }
>
>
> public static void add_good() throws Exception{
>
> Service service = new Service(new URL(wsdlURL), new QName("http://tempuri.org/","MathService"));
> Call _call = (Call)(service.createCall(new QName("http://tempuri.org/","MathServiceSoap"),
> new QName("http://tempuri/org/","Add")));
> _call.setSOAPActionURI("http://tempuri.org/Add");
> _call.setOperationStyle(Style.WRAPPED);
> System.out.println(" Response from add_good is " + _call.invoke(new Object[] {new Float(12) , new Float(12)}));
> }
>
> public static void add_bad() throws Exception{
>
> Service service = new Service();
> Call _call = (Call)(service.createCall());
>
> _call.setUseSOAPAction(true);
> _call.setSOAPActionURI("http://tempuri.org/Add");
>
> _call.setTargetEndpointAddress( new java.net.URL(endpoint) );
> _call.setOperationStyle(Style.WRAPPED);
>
> _call.setOperationName(new QName("http://tempuri.org/","Add"));
> _call.addParameter("A",org.apache.axis.Constants.XSD_FLOAT,Float.class,ParameterMode.IN);
> _call.addParameter("B",org.apache.axis.Constants.XSD_FLOAT,Float.class,ParameterMode.IN);
>
> _call.setReturnClass(Float.class);
>
> System.out.println(" Response from add_bad is " + _call.invoke(new Object[] {new Float(12) , new Float(12)}));
> }
>}
>