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 mi...@nutechs.com on 2003/06/12 16:07:15 UTC

Follow-up on invoking web service




Hi,

First of all, thanks to Vlad Umansky for helping me get to the point where
I can invoke the Unisys Weather web service.  My code now successfully
invokes the web service and gets a response.  Unfortunately, no matter what
zip code value I supply as the input parameter, I always get back the same
response, which is the weather for Kennett Square, PA.  I've e-mailed with
the owner of the web service, and he told me that Kennett Square is the
default zip code used by the web service when the input parameter provided
to it is invalid.  I've looked at the WSDL for the web service, but didn't
notice anything that signified that the input parameter should be anything
other than a string.  I've defined the input parm as XSD_STRING and
SOAP_STRING, with no change in results.  I've attached the URL for the web
service and my Java code below.  Could someone take a look for me and let
me know what I'm doing wrong?  As before, all help is appreciated.

http://weather.unisysfsp.com/PDCWebService/WeatherServices.asmx?WSDL

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

import javax.xml.namespace.QName;

public class TestClient2
{
   public static void main(String [] args) {
       try {

           // the service location
           String endpoint = "http://weather.unisysfsp.com/PDCWebService/WeatherServices.asmx?wsdl";

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

           call.setTargetEndpointAddress( new java.net.URL(endpoint) );

           // the operation
           call.setOperationName(new QName ( "GetWeatherText" ) );

           // the SOAPAction
           call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://www.unisys.com/WebServices/GetWeatherText" );

           //call.addParameter ( "ZipCode", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN );
           call.addParameter ( "ZipCode", org.apache.axis.Constants.SOAP_STRING, javax.xml.rpc.ParameterMode.IN );

           call.setReturnType ( org.apache.axis.Constants.XSD_STRING );

           String ret = (String) call.invoke ( new Object[] { args[0] } );

           System.out.println("Sent: '" + args[0] + "', got: '" + ret + "'");

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


Thanks,

Michael Sobczak
NuTechs, Inc.
6785 Telegraph Road, Suite 350
Bloomfield Hills, MI 48301
pager: (248) 316-6524


Re: Follow-up on invoking web service

Posted by Mathew Hreljac <mh...@exchangesolutions.net>.
.NET services require a SOAPAction to be set (usually the URI to it,
might be an alias) in order to work.  Just add whatever the service
requires for a SOAPAction and it should be fine.

Matty


On Thu, 2003-06-12 at 10:07, michael_sobczak@nutechs.com wrote:
> 
> 
> Hi,
> 
> First of all, thanks to Vlad Umansky for helping me get to the point where
> I can invoke the Unisys Weather web service.  My code now successfully
> invokes the web service and gets a response.  Unfortunately, no matter what
> zip code value I supply as the input parameter, I always get back the same
> response, which is the weather for Kennett Square, PA.  I've e-mailed with
> the owner of the web service, and he told me that Kennett Square is the
> default zip code used by the web service when the input parameter provided
> to it is invalid.  I've looked at the WSDL for the web service, but didn't
> notice anything that signified that the input parameter should be anything
> other than a string.  I've defined the input parm as XSD_STRING and
> SOAP_STRING, with no change in results.  I've attached the URL for the web
> service and my Java code below.  Could someone take a look for me and let
> me know what I'm doing wrong?  As before, all help is appreciated.
> 
> http://weather.unisysfsp.com/PDCWebService/WeatherServices.asmx?WSDL
> 
> import org.apache.axis.client.Call;
> import org.apache.axis.client.Service;
> 
> import javax.xml.namespace.QName;
> 
> public class TestClient2
> {
>    public static void main(String [] args) {
>        try {
> 
>            // the service location
>            String endpoint = "http://weather.unisysfsp.com/PDCWebService/WeatherServices.asmx?wsdl";
> 
>            Service  service = new Service();
>            Call     call    = (Call) service.createCall();
> 
>            call.setTargetEndpointAddress( new java.net.URL(endpoint) );
> 
>            // the operation
>            call.setOperationName(new QName ( "GetWeatherText" ) );
> 
>            // the SOAPAction
>            call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://www.unisys.com/WebServices/GetWeatherText" );
> 
>            //call.addParameter ( "ZipCode", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN );
>            call.addParameter ( "ZipCode", org.apache.axis.Constants.SOAP_STRING, javax.xml.rpc.ParameterMode.IN );
> 
>            call.setReturnType ( org.apache.axis.Constants.XSD_STRING );
> 
>            String ret = (String) call.invoke ( new Object[] { args[0] } );
> 
>            System.out.println("Sent: '" + args[0] + "', got: '" + ret + "'");
> 
>        } catch (Exception e) {
>            System.err.println(e.toString());
>        }
>    }
> }
> 
> 
> Thanks,
> 
> Michael Sobczak
> NuTechs, Inc.
> 6785 Telegraph Road, Suite 350
> Bloomfield Hills, MI 48301
> pager: (248) 316-6524
-- 
Mathew Hreljac <mh...@exchangesolutions.net>

Re: Follow-up on invoking web service

Posted by Davanum Srinivas <di...@yahoo.com>.
Try attached file.

-- dims

--- michael_sobczak@nutechs.com wrote:
> 
> 
> 
> 
> Hi,
> 
> First of all, thanks to Vlad Umansky for helping me get to the point where
> I can invoke the Unisys Weather web service.  My code now successfully
> invokes the web service and gets a response.  Unfortunately, no matter what
> zip code value I supply as the input parameter, I always get back the same
> response, which is the weather for Kennett Square, PA.  I've e-mailed with
> the owner of the web service, and he told me that Kennett Square is the
> default zip code used by the web service when the input parameter provided
> to it is invalid.  I've looked at the WSDL for the web service, but didn't
> notice anything that signified that the input parameter should be anything
> other than a string.  I've defined the input parm as XSD_STRING and
> SOAP_STRING, with no change in results.  I've attached the URL for the web
> service and my Java code below.  Could someone take a look for me and let
> me know what I'm doing wrong?  As before, all help is appreciated.
> 
> http://weather.unisysfsp.com/PDCWebService/WeatherServices.asmx?WSDL
> 
> import org.apache.axis.client.Call;
> import org.apache.axis.client.Service;
> 
> import javax.xml.namespace.QName;
> 
> public class TestClient2
> {
>    public static void main(String [] args) {
>        try {
> 
>            // the service location
>            String endpoint =
> "http://weather.unisysfsp.com/PDCWebService/WeatherServices.asmx?wsdl";
> 
>            Service  service = new Service();
>            Call     call    = (Call) service.createCall();
> 
>            call.setTargetEndpointAddress( new java.net.URL(endpoint) );
> 
>            // the operation
>            call.setOperationName(new QName ( "GetWeatherText" ) );
> 
>            // the SOAPAction
>            call.setProperty(Call.SOAPACTION_URI_PROPERTY,
> "http://www.unisys.com/WebServices/GetWeatherText" );
> 
>            //call.addParameter ( "ZipCode", org.apache.axis.Constants.XSD_STRING,
> javax.xml.rpc.ParameterMode.IN );
>            call.addParameter ( "ZipCode", org.apache.axis.Constants.SOAP_STRING,
> javax.xml.rpc.ParameterMode.IN );
> 
>            call.setReturnType ( org.apache.axis.Constants.XSD_STRING );
> 
>            String ret = (String) call.invoke ( new Object[] { args[0] } );
> 
>            System.out.println("Sent: '" + args[0] + "', got: '" + ret + "'");
> 
>        } catch (Exception e) {
>            System.err.println(e.toString());
>        }
>    }
> }
> 
> 
> Thanks,
> 
> Michael Sobczak
> NuTechs, Inc.
> 6785 Telegraph Road, Suite 350
> Bloomfield Hills, MI 48301
> pager: (248) 316-6524
> 

=====
Davanum Srinivas - http://webservices.apache.org/~dims/

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com