服务器端的服务发布是成功的,能够访问到WSDL,在本地测试也可以通过,但是把代码移植正式机上面,就会报错,客户端代码如下!
- Java code
private static final String wsdlUrl = "http://****/services/MyService?wsdl"; private static final String nameSpaceUri = "http://****services/MyService"; private static final String userName="myName"; private static final String password="123456";
- Java code
private static String callService(String method, String request) { try { Service service = new Service(); Call call = null; call = (Call) service.createCall(); // 调用 getMessage // System.out.println(">>>getMessage"); call.setOperationName(new QName(nameSpaceUri, method)); call.setTargetEndpointAddress(new java.net.URL(wsdlUrl)); String ret = (String) call.invoke(new Object[] { userName, password,java.net.URLEncoder.encode(request, "UTF-8") }); ret = java.net.URLDecoder.decode(ret, "UTF-8"); JSONObject a = new JSONObject(ret); System.out.println("return value is " + ret); return ret; } catch (Exception e) { e.printStackTrace(); return "0"; } }
- Java code
private static String sendMessage(String phone,String msgContent,String sendTime){ String method="sendMessage"; String phoneParm="destTermId"; String msgParm="msgContent"; String sendTimeParm="sendTime"; JSONObject jsObject = new JSONObject(); try { jsObject.put(phoneParm, phone); jsObject.put(msgParm, msgContent); jsObject.put(sendTimeParm, sendTime); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return callService(method, jsObject.toString()); }
- Java code
public static void main(String[] args) { String result = sendMessage("134****5152","This is the message test, said after receipt of normal! Need not ignore! Thank you! [Remote medical treatment] ",""); System.out.println(result); //System.out.println(getStatus()); //smsRecord(); }
在其他人机器上面调用在正式机上发布的服务时候,他就会报异常,
- Java code
8-22 09:48:49 DEBUG org.apache.axis.client.Call:2445 - Mapping Exception to AxisFaultAxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: java.lang.reflect.InvocationTargetException faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}hostname:RH-MISP-17java.lang.reflect.InvocationTargetException at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222) at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129) at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source) at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) at org.apache.axis.Message.getSOAPEnvelope(Message.java:435) at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796) at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) at org.apache.axis.client.Call.invokeEngine(Call.java:2784) at org.apache.axis.client.Call.invoke(Call.java:2767) at org.apache.axis.client.Call.invoke(Call.java:2443) at org.apache.axis.client.Call.invoke(Call.java:2366) at org.apache.axis.client.Call.invoke(Call.java:1812) at com.gdcct.ctp.telemedicine.service.TestService.callService(TestService.java:72) at com.gdcct.ctp.telemedicine.service.TestService.sendMessage(TestService.java:57) at com.gdcct.ctp.telemedicine.service.TestService.main(TestService.java:24)AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: java.lang.reflect.InvocationTargetException faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}hostname:RH-MISP-17java.lang.reflect.InvocationTargetException at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222) at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129) at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source) at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) at org.apache.axis.Message.getSOAPEnvelope(Message.java:435) at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796) at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) at org.apache.axis.client.Call.invokeEngine(Call.java:2784) at org.apache.axis.client.Call.invoke(Call.java:2767) at org.apache.axis.client.Call.invoke(Call.java:2443) at org.apache.axis.client.Call.invoke(Call.java:2366) at org.apache.axis.client.Call.invoke(Call.java:1812) at com.gdcct.ctp.telemedicine.service.TestService.callService(TestService.java:72) at com.gdcct.ctp.telemedicine.service.TestService.sendMessage(TestService.java:57) at com.gdcct.ctp.telemedicine.service.TestService.main(TestService.java:24)