日期:2014-05-19  浏览次数:21212 次

求助:关于Axis 客户端接口调用报错问题。
服务器端的服务发布是成功的,能够访问到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 AxisFault
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-17

java.lang.reflect.InvocationTargetException
    at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
    at org.apache.