java.net.UnknownHostException: XXX 域名解析问题

  • Post author:
  • Post category:java


短信发送功能中要调用公司的短信接口,发现报错:

[ERROR,HttpChannel,http-80-15] java.net.UnknownHostException: XXX.XXX.XX

org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Couldn’t send message.

org.codehaus.xfire.fault.XFireFault: Couldn’t send message.

at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)

at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:30)

at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)

at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)

at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)

at org.codehaus.xfire.client.Client.invoke(Client.java:336)

at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)

at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)

at $Proxy46.send1(Unknown Source)

at com.sdfey.common.util.SmsUtils.send1(SmsUtils.java:57)

at com.sdfey.servlet.ReadExl2.doPost(ReadExl2.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:615)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)

at java.lang.Thread.run(Unknown Source)

Caused by: org.codehaus.xfire.XFireException: Couldn’t send message.

at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:145)

at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)

at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)

… 35 more

Caused by: java.net.UnknownHostException: sms.szpay.net

at java.net.PlainSocketImpl.connect(Unknown Source)

at java.net.SocksSocketImpl.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at java.net.Socket.<init>(Unknown Source)

at java.net.Socket.<init>(Unknown Source)

at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:79)

at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:121)

at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:706)

at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1321)

at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:386)

at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)

at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)

at org.codehaus.xfire.transport.http.CommonsHttpMessageSender.send(CommonsHttpMessageSender.java:369)

at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:123)

… 37 more

换成IP地址就行了

比如:

http://sms.szpay.net:…..

===>

http://120.195.10.34:…..

后来又报

org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: There must be a method name element.

org.codehaus.xfire.fault.XFireFault: There must be a method name element.

at org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:32)

at org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42)

at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)

at org.codehaus.xfire.client.Client.onReceive(Client.java:406)

at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)

at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)

at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)

at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)

at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)

at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)

at org.codehaus.xfire.client.Client.invoke(Client.java:336)

at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)

at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)

at $Proxy46.send1(Unknown Source)

at com.sdfey.common.util.SmsUtils.send1(SmsUtils.java:57)

at com.sdfey.servlet.ReadExl2.doPost(ReadExl2.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:615)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)

at java.lang.Thread.run(Unknown Source)

看到代码中有这句:

private static XFireProxyFactory proxyFactory = new XFireProxyFactory();

需要把访问路径的

WSDL

去掉,

类似于

http://www.12580sky.com/xfire/demoCommonService?WSDL

==>

http://www.12580sky.com/xfire/demoCommonService



版权声明:本文为weilikk原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。