本帖最后由 u010784851 于 2014-10-08 08:49:19 编辑

解决方案 »

  1.   

    看看这个文件的chatmanage.asmx命名空间是不是正确
      

  2.   

    调用第三方webservice api要严格按照别人提供的调用方式。这个错误信息告诉你,无法识别你的soapaction,那你就不要设置soapactionname了,改为soapaction。
      

  3.   

    文件地址:
    http://appkey.imjuju.com:8200/api/chatmanage.asmx
    访问的 UserLogin
      

  4.   

    把这个文件贴出来看看
    文件地址:
    http://appkey.imjuju.com:8200/api/chatmanage.asmx
    访问的 UserLogin
      

  5.   

    import java.util.Set;
    import java.util.Vector;import org.apache.soap.Constants;
    import org.apache.soap.Fault;
    import org.apache.soap.SOAPException;
    import org.apache.soap.rpc.Call;
    import org.apache.soap.rpc.Parameter;
    import org.apache.soap.rpc.Response;public class WebServiceUtil {
           public static String getService(String requesturl,Map parameters) {
            URL url = null;
            try {
            url=new URL(requesturl);
            } catch (MalformedURLException mue) {
            return mue.getMessage();
            }
                 // This is the main SOAP object
            Call soapCall = new Call();
            // Use SOAP encoding
          //http://appkey.imjuju.com:8200/api/chatmanage.asmx/UserLogin
            //?loginname=no1&loginpwd=123456&lat=1213&lng=79 
            //soapCall.setEncodingStyleURI("http://schemas.xmlsoap.org/soap/encoding/");
            soapCall.setEncodingStyleURI( Constants.NS_URI_SOAP_ENC);
            // This is the remote object we're asking for the price
            soapCall.setTargetObjectURI("urn:xmethods-ChatManage");
            // This is the name of the method on the above object
            soapCall.setMethodName("UserLogin");
            // We need to send the ISBN number as an input parameter to the method
            Vector soapParams = new Vector();
            // name, type, value, encoding style
            if(parameters!=null){
            Set<String> set = parameters.keySet();
            Parameter isbnParam = null;
            for(String key:set){
            isbnParam = new Parameter(key, String.class, parameters.get(key),null);
            soapParams.addElement(isbnParam);
            }
            }
            soapCall.setParams(soapParams);
           try {
              // Invoke the remote method on the object
              Response soapResponse = soapCall.invoke(url,"");
              // Check to see if there is an error, return "N/A"
              if (soapResponse.generatedFault()) {
                 Fault fault = soapResponse.getFault();
                 String f = fault.getFaultString();
                 return f;
              } else {
                 // read result
                 Parameter soapResult = soapResponse.getReturnValue ();
                 // get a string from the result
                 return soapResult.getValue().toString();
              }
           } catch (SOAPException se) {
              return se.getMessage();
           }     }
           
           public static void main(String[] args) {
            String url ="http://appkey.imjuju.com:8200/api/chatmanage.asmx";
            Map<String,String> parameters = new HashMap<String, String>();
            parameters.put("loginname", "no1");
            parameters.put("loginpwd","123456");
            parameters.put("lat","123456");
            parameters.put("lng","123456");
            String a = getService(url, parameters);
            System.out.println(a);
    }
    }一样的错误:
    System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: .
       at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
       at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
       at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
      

  6.   

    不知道你解决了没,为了方便用的xfire,jar官方下载即可:@Test
    public void testUserLogin(){
    try {
    String methodName = "UserLogin";
    String userName = "no1";
    String passWord = "123456";
    float lat = 1.2f;
    float lng = 1.20f;
    String url = "http://appkey.imjuju.com:8200/api/chatmanage.asmx?wsdl";
    Client client = new Client(new URL(url));

    Object[] resultInfo = client.invoke(methodName,new Object[]{userName,passWord,lat,lng});
    if (null != resultInfo && resultInfo.length > 0) {
    System.out.println(resultInfo[0]);
    }
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
      

  7.   

    引用 8 楼 ix_fly 的回复:
    不知道你解决了没,为了方便用的xfire,jar官方下载即可:@Test
    public void testUserLogin(){
    try {
    String methodName = "UserLogin";
    String userName = "no1";
    String passWord = "123456";
    float lat = 1.2f;
    float lng = 1.20f;
    String url = "http://appkey.imjuju.com:8200/api/chatmanage.asmx?wsdl";
    Client client = new Client(new URL(url));

    Object[] resultInfo = client.invoke(methodName,new Object[]{userName,passWord,lat,lng});
    if (null != resultInfo && resultInfo.length > 0) {
    System.out.println(resultInfo[0]);
    }
    } catch (Exception e) {
    e.printStackTrace();
    }
    }