Reputation: 448
I am trying to send a request to this web service in order to get the response: This is my java code
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
public class TestClient {
public static void main(String[] args) {
try {
String endpoint ="http://www.webservicex.net/geoipservice.asmx";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://www.webservicex.net/","GetGeoIP"));
String response = (String) call.invoke(new Object[] { "192.168.1.8" });
System.out.println("The response is : " + response);
} catch (Exception e) {
System.err.println(e.toString());
}
}
}
When i run this code i get this soapException:
Server did not recognize the value of HTTP Header SOAPAction:
Can any one help how can i solve this?
Upvotes: 1
Views: 7217
Reputation: 807
This may happen when the ws host value is different from the namespace value as below:
<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.hostname.com/example" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://www.namespace.com/example" slick-uniqueid="3">
So if the web service you are trying to send requests is being moved, sometimes they only change the host and not the namespace.
In order to use "example" with Axis, you have to update the host value and not the namespace value. It should look like this in
ExampleLocator.java
class (as the Locator class is where you set the host in axis):
ExampleSoap_address = "http://www.hostname.com/xxx/example.asmx"
And namespace values should stay the same as below:
targetNamespace="http://www.namespace.com/example"
But the guaranteed way of doing this is creating the stubs again from scratch, checking the usages of the new hostname values in the code and updating your old code for those usages.
Upvotes: 1
Reputation: 446
Looking at the web service wsdl you have to change "GetGeoIP" with
"http://www.webservicex.net/GetGeoIP"
.
Finally you have
call.setOperationName(new QName("http://www.webservicex.net/","http://www.webservicex.net/GetGeoIP"));
Try it.
Upvotes: 0