异常代码如下:System.Web.Services.Protocols.SoapException: 服务器未能识别 HTTP 头 SOAPAction 的值: http://tempuri.org/GetSDCities。
   在 System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
   在 System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
   在 System.Web.Services.Protocols.SoapServerProtocol.Initialize()
   在 System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
   在 System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:251)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:168)
at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1001)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2939)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:377)
at org.apache.axis.client.Call.invokeEngine(Call.java:2545)
at org.apache.axis.client.Call.invoke(Call.java:2515)
at org.apache.axis.client.Call.invoke(Call.java:2210)
at org.apache.axis.client.Call.invoke(Call.java:2133)
at org.apache.axis.client.Call.invoke(Call.java:1656)
at com.avis.test.AvisDemo.testDemo4(AvisDemo.java:137)
at com.avis.test.AvisDemo.main(AvisDemo.java:149)
代码:public static void testDemo4() {
String url = "http://203.148.56.10/WebService/AvisRentalService.asmx";
String namespace = "http://tempuri.org/";
String methodName = "GetSDCities";
String soapActionURI = "http://tempuri.org/GetSDCities"; Service service = new Service();
Call call;
try {
call = (Call) service.createCall();

call.setTargetEndpointAddress(url);
call.setUseSOAPAction(true);
call.setSOAPActionURI(soapActionURI);
call.setOperationName(new QName(namespace, methodName)); call.addParameter(new QName(namespace, "LoginName"), XMLType.XSD_STRING,ParameterMode.IN);
call.addParameter(new QName(namespace, "Password"), XMLType.XSD_STRING,ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING); String[] str = new String[2];
str[0] = "[email protected]";
str[1] = "zI9Fvh4NmMA="; Object obj = call.invoke(str);
System.out.println("obj + " + obj);
} catch (ServiceException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
}

解决方案 »

  1.   

    这样试试看:private static HttpClient httpclient; public static HttpClient getHttpClient() {
    if (httpclient != null)
    return httpclient; // SimpleHttpConnectionManager默认是false,connection是不会被主动关闭的,因此要设置为true,这里很关键
    httpclient = new HttpClient(new HttpClientParams(), new SimpleHttpConnectionManager(true));
    return httpclient;
    }

    public static void getQuestionList() {
    HttpClient httpclient = getHttpClient();
    String url = "http://203.148.56.10/WebService/AvisRentalService.asmx?op=GetSDLocations&[email protected]&Password=zI9Fvh4NmMA=";
    GetMethod get = new GetMethod(url) {
    public String getRequestCharSet() {
    return "UTF-8";
    }
    }; try {
    int result = httpclient.executeMethod(get);
    if (result != 200) {
    return;
    } String xml = get.getResponseBodyAsString();
    get.releaseConnection();
    System.out.println(xml);

    } catch (Exception e) {
    e.printStackTrace();
    get.releaseConnection();
    }
    }
      

  2.   


    官网的API是这样写的。
    1.2 用户验证方式
    验证方式为在每个SOAP的消息头部写入用户名和密码,如下:
    <soap:Header>
        <ValidationSoapHeader xmlns="http://tempuri.org/">
            <LoginName>TestID</LoginName>
            <Password>*****</Password>
        </ValidationSoapHeader>
    </soap:Header>
    系统将会对用户名和密码进行验证,只有通过后才可以访问数据接口;
    1.3 SOAP信息Sample
    以下是 SOAP 1.1 请求和响应示例。所显示的占位符需替换为实际值。
    POST /webservice/AvisRentalService.asmx HTTP/1.1
    Host: www.avischina.com
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    SOAPAction: "http://tempuri.org/AddOrder"
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Header>
            <ValidationSoapHeader xmlns="http://tempuri.org/">
                <LoginName>string</LoginName>
                <Password>string</Password>
            </ValidationSoapHeader>
        </soap:Header>
    <soap:Body>
    <Date>
            <AddOrder xmlns="http://tempuri.org/">
                <Orderinfo>string</Orderinfo>
            </AddOrder>
        </Data>
        </soap:Body>
    </soap:Envelope>
    2 基础数据Web Service
    2.1 获取自驾城市列表
    Request XML:
    XML样例
            <Data>
    <Method>GetSDCities</Method>
            </Data>Response XML:
    XML样例
    <Data>
        <ReturnValue>
            <Code>ACK</Code>
            <Description>成功</Description>
        </ReturnValue>
        <Citylist>
            <City>
                <CityCode>310010</CityCode>
                <Name>上海</Name>
            </City>
            <City>
                <CityCode>320500</CityCode>
                <Name>苏州</Name>
            </City>
        </Citylist>
    </Data>Response XML node Description:
    XML节点 类型 参数说明
    ReturnValue
    Code String 错误编号
    ACK:成功
    PWD:账号或者密码不正确
    ERR:其它错误
    Description String 错误信息描述
    City
    CityCode String 城市编码
    Name String 城市名
      

  3.   

    public class axis {
        public static void main(String[] args){
       String aa;
       String bb;
       String cc;
      
       try {
      String endpoint="http://www.tangs.com/"; 
      Service service = new Service();
      Call call = (Call)service.createCall();
      call.setTargetEndpointAddress(new java.net.URL(endpoint));
      //call.setOperationName("GetJobList");
      call.setOperationName(new QName("http://www.tangs.com/","Add")); // 
      
      // 设置要调用的方法  注意org.apache.axis.encoding.XMLType.XSD_STRING  类型要和对方接口文档类型一致
       call.addParameter(new QName("http://www.tangs.com/", "aa"), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
       call.addParameter(new QName("http://www.tangs.com/", "bb"), org.apache.axis.encoding.XMLType.XSD_INT, javax.xml.rpc.ParameterMode.IN);
       call.addParameter(new QName("http://www.tangs.com/", "cc"), org.apache.axis.encoding.XMLType.XSD_DATETIME, javax.xml.rpc.ParameterMode.IN);
      
       
      // 方法的返回值类型
      call.setReturnType(org.apache.axis.encoding.XMLType.XSD_SCHEMA); 
      call.setUseSOAPAction(true);
      call.setSOAPActionURI("http://www.tangs.com/","Add"));  
      Schema result = (Schema)call.invoke(new Object[]{
         aa= "程序员",                                     
         bb= "传给对方的参数(对方没有必传参数可以不传)",                                     
         cc= "传给对方的参数",                                     
            });
       //调用方法并传递参数
      
        
         int length = result.get_any()[1].getChildNodes().item(0).getChildNodes().getLength();
         
            for(int j= 0 ;j < length ;j ++){
             System.out.println(result.get_any()[1].getChildNodes().item(0));
       for (int i = 0; i < 10; i++) { 
        System.out.println(result.get_any()[1].getChildNodes().item(0).getChildNodes().item(0).getChildNodes().item(i).getFirstChild().getNodeValue());
       } 
            } 
       } catch (Exception e) { 
       e.printStackTrace(); 
       } 
       
       } }看下我这个吧!java调用C# axis的  传入相应的值可以运行。。
      

  4.   

    现在出现才异常信息:System.Web.Services.Protocols.SoapException: 服务器未能识别 HTTP 头 SOAPAction 的值: 。
       在 System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
       在 System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
       在 System.Web.Services.Protocols.SoapServerProtocol.Initialize()
       在 System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
       在 System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
    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 com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2939)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
    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.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    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.avis.test.AvisDemo.testDemo7(AvisDemo.java:250)
    at com.avis.test.AvisDemo.main(AvisDemo.java:263)
      

  5.   

    现在出现这样的异常:AxisFault
     faultCode: {http://www.w3.org/2003/05/soap-envelope}Receiver
     faultSubcode: 
     faultString: System.Web.Services.Protocols.SoapException: 服务器无法处理请求。 ---&gt; System.NullReferenceException: 未将对象引用设置到对象的实例。