Reputation: 115
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());
}
Upvotes: 0
Views: 1075
Reputation: 487
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"));
Upvotes: 1