简体   繁体   中英

SOAPACTION_URI_PROPERTY in Call webservice with axis

I want to call web service with axis.I want to use this code. Can somebody tell me what should be the value for Call.SOAPACTION_URI_PROPERTY?

code:

         try {

        String endpoint =  "http://www.w3schools.com/webservices/tempconvert.asmx";

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

        call.setProperty( Call.SOAPACTION_USE_PROPERTY, new Boolean( true ) );
        call.setProperty( Call.SOAPACTION_URI_PROPERTY, "http://tempuri.org/CelsiusToFahrenheit");

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

        String ret = (String) call.invoke( new Object[] {"20"} );
        System.out.println("Sent '20', got '" + ret + "'");

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

In this line

call.setProperty( Call.SOAPACTION_USE_PROPERTY, new Boolean( true ) );
call.setProperty( Call.SOAPACTION_URI_PROPERTY, "http://tempuri.org/CelsiusToFahrenheit");

You are telling that you want to specify a soap action and that the soap action is CelsiusToFahrenheit.

The SOAP action is not manduatory and can be used to tell a Webservice which method you want to execute. Edit :

So the value to assign depends on the specification in you wsdl. You should find a few tags named "operation name='something'" to see what operation are defined for the WS.

Try to replace

call.setOperationName(new QName("http://tempuri.org/CelsiusToFahrenheit","CelsiusToFahrenheit"));

with

call.setOperationName(new QName("http://tempuri.org","CelsiusToFahrenheit"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM