轉自:https://blog.csdn.net/dxfasr/article/details/25029063
在用java發送給webservice服務器的時候報如下錯誤:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
faultSubcode:
faultString: 服務器未能識別 HTTP 頭 SOAPAction 的值: 。
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:服務器未能識別 HTTP 頭 SOAPAction 的值: 。
解決辦法:
Call call = (Call)service.createCall();
//加入如下的方法:在調用的時候直接寫
call.setSOAPActionURI(http://rb-ht.com/方法名);
寫好的調用的例子如下:
public static String invokeRemoteAddr(String wsdl, String method,
Object[] objects) throws Exception {
Service service = new Service();
Call call;
try {
call = (Call) service.createCall();
call.setSOAPActionURI("http://tempuri.org/receiveDataTask");
call.setTargetEndpointAddress(wsdl);
call.setOperationName(method);// WSDL里面描述的接口名稱
call.addParameter("orig",
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);// 接口的參數
call.addParameter("sign",
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);// 接口的參數
call.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);// 設置返回類型
call.invoke(objects);
return "end";
} catch (ServiceException e) {
throw new Exception(e);
}
}
如果修改后還是有錯誤:
這個時候仔細檢查targetNameSpace命名空間是否正確、配置正確后、即可