RPC调用本机的跑的webservice Unable to sendViaPost to url

xiaodou18 2016-12-08 10:46:02
我本机跑了webservice 是可以访问的:

测试代码:

public class HttpClientWSTest {

public static void main(String[] args) throws HttpException, IOException {
// TODO Auto-generated method stub

HttpClientWSTest call = new HttpClientWSTest(
"http://impl.server.soap.webservice.jfit.com/", "sendMessage",
"http://192.168.22.235:8088/mp/services?wsdl");

call.rPcAxis2Ws();
//call.httpClientSoap();

}


private String namespace;
private String methodName;
private String wsdlLocation;
private String soapResponseData;

public HttpClientWSTest(String namespace, String methodName,String wsdlLocation) {
this.namespace = namespace;
this.methodName = methodName;
this.wsdlLocation = wsdlLocation;
}



/**
* RPC方式
*/

private void rPcAxis2Ws(){

try {
RPCServiceClient client = new RPCServiceClient();
Options options = client.getOptions();
EndpointReference targetEPR = new EndpointReference(wsdlLocation);
options.setTo(targetEPR);
options.setProperty(HTTPConstants.CHUNKED, false);
//options.setAction(namespace);
//指定命名空间和方法
QName qName = new QName(namespace,methodName);
//指定调用参数
// Object[] opAddEntryArgs = new Object[] {"xiejianping","210","1","5"};
Object[] opAddEntryArgs = new Object[] {"10272","85204c4b84214a89b5c00f2e0f43dbdd","接口测试112","","fugl"};
//指定返回类型
Class[] returnTypes = new Class[] { Object.class};
//调用方法并输出该方法的返回值

Object[] response = client.invokeBlocking(qName, opAddEntryArgs, returnTypes);
//为了防止连接超时
System.out.println("response=="+response);
client.cleanupTransport();
} catch (AxisFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}



}

String xml ="<?xml version=\"1.0\" encoding=\"utf-8\"?><soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ser='http://server.soap.webservice.jfit.com/'>"
+"<soapenv:Header/>"
+"<soapenv:Body>"
+"<ser:sendMessage>"
+"<!--Optional:-->"
+"<client_ID>10272</client_ID>"
+"<!--Optional:-->"
+"<service_ID>85204c4b84214a89b5c00f2e0f43dbdd</service_ID>"
+"<!--Optional:-->"
+"<content>接口测试2</content>"
+"<!--Optional:-->"
+"<linkUrl></linkUrl>"
+"<!--Optional:-->"
+"<receiveIds>fugl</receiveIds>"
+"</ser:sendMessage>"
+"</soapenv:Body>"
+"</soapenv:Envelope>";
/**
* httpClient 发送 soap方式
*
* @throws HttpException
* @throws IOException
*/
public void httpClientSoap() throws HttpException, IOException{
PostMethod postMethod = new PostMethod(wsdlLocation);

// 然后把Soap请求数据添加到PostMethod中
byte[] b = xml.getBytes("utf-8");
InputStream is = new ByteArrayInputStream(b, 0, b.length);
RequestEntity re = new InputStreamRequestEntity(is, b.length,
"application/xml; charset=utf-8");
//postMethod.setRequestEntity(re);
StringRequestEntity requestEntity=new StringRequestEntity(xml.toString());
postMethod.setRequestEntity(requestEntity);
// 最后生成一个HttpClient对象,并发出postMethod请求
HttpClient httpClient = new HttpClient();
int statusCode = httpClient.executeMethod(postMethod);
if(statusCode == 200) {
System.out.println("调用成功!");
String soapResponseData = postMethod.getResponseBodyAsString();
System.out.println(soapResponseData);
}
else {
System.out.println("调用失败!错误码:" + statusCode);
}

}


}

==========================================================
call.httpClientSoap();
call.HttpURLConnectionSoap(); 这2个是可以调通的。


call.rPcAxis2W()报错
日志:

710 DEBUG [2016-12-08 09:27:54] end getBytes()
715 INFO [2016-12-08 09:27:54] I/O exception (org.apache.commons.httpclient.NoHttpResponseException) caught when processing request: The server 192.168.22.235 failed to respond
716 INFO [2016-12-08 09:27:54] Retrying request
721 INFO [2016-12-08 09:27:54] I/O exception (org.apache.commons.httpclient.NoHttpResponseException) caught when processing request: The server 192.168.22.235 failed to respond
722 INFO [2016-12-08 09:27:54] Retrying request
727 INFO [2016-12-08 09:27:54] I/O exception (org.apache.commons.httpclient.NoHttpResponseException) caught when processing request: The server 192.168.22.235 failed to respond
727 INFO [2016-12-08 09:27:54] Retrying request
735 INFO [2016-12-08 09:27:54] Unable to sendViaPost to url[http://192.168.22.235:8088/mp/services?wsdl]
org.apache.commons.httpclient.NoHttpResponseException: The server 192.168.22.235 failed to respond
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1835)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1590)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:995)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:520)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:191)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:327)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:206)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:396)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:374)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508)
at org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:101)
at Test1.HttpClientWSTest.rPcAxis2Ws(HttpClientWSTest.java:139)
at Test1.HttpClientWSTest.main(HttpClientWSTest.java:50)
738 DEBUG [2016-12-08 09:27:54] org.apache.axis2.AxisFault: The server 192.168.22.235 failed to respond
738 DEBUG [2016-12-08 09:27:54] org.apache.axis2.AxisFault: The server 192.168.22.235 failed to respond
739 DEBUG [2016-12-08 09:27:54] [MessageContext: logID=urn:uuid:AF8D5FFDAB1568743F1481160474150] Invoking flowComplete() in Phase "Security"
739 DEBUG [2016-12-08 09:27:54] [MessageContext: logID=urn:uuid:AF8D5FFDAB1568743F1481160474150] Invoking flowComplete() in Phase "MessageOut"
739 DEBUG [2016-12-08 09:27:54] [MessageContext: logID=urn:uuid:AF8D5FFDAB1568743F1481160474150] Invoking flowComplete() in Phase "PolicyDetermination"
739 DEBUG [2016-12-08 09:27:54] [MessageContext: logID=urn:uuid:AF8D5FFDAB1568743F1481160474150] Invoking flowComplete() in Phase "RMPhase"
739 DEBUG [2016-12-08 09:27:54] [MessageContext: logID=urn:uuid:AF8D5FFDAB1568743F1481160474150] Invoking flowComplete() in Phase "OperationOutPhase"
org.apache.axis2.AxisFault: The server 192.168.22.235 failed to respond
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:417)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:195)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:327)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:206)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:396)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:374)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508)
at org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:101)
at Test1.HttpClientWSTest.rPcAxis2Ws(HttpClientWSTest.java:139)
at Test1.HttpClientWSTest.main(HttpClientWSTest.java:50)
Caused by: org.apache.commons.httpclient.NoHttpResponseException: The server 192.168.22.235 failed to respond
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1835)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1590)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:995)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:520)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:191)
... 12 more
...全文
1540 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,528

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧