package com.iip.kma.test;import javax.xml.namespace.QName;import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
public class WebServiceTest {
  
    private static EndpointReference targetEPR =
        new EndpointReference(
               "http://localhost:8989/axis2/services/SpringAwareService");
 
    public static void main(String[] args1) throws AxisFault{
    
        RPCServiceClient serviceClient = new RPCServiceClient();
        Options options = serviceClient.getOptions();
        options.setTo(targetEPR);    
        
        
        QName opFindEntry = new QName("http://logic.kma.iip.com", "getAppNodeList");
        Object[] opFindEntryArgs = new Object[] {"4", "1", "1"};
        Class[] returnTypes = new Class[] { String.class }; 
        Object[] response = serviceClient.invokeBlocking(opFindEntry,
                opFindEntryArgs, returnTypes);
        
        String result = (String) response[0];   
        System.out.println("begin.");
        System.out.println(result); 
        System.out.println("ok");                                  
    }
   
}

解决方案 »

  1.   

    错误可能是xFire版本支持的WebService 标准和服务端支持的标准不一致,不能正确解析wsdl.
      

  2.   

    QName opFindEntry = new QName("http://logic.kma.iip.com", "getAppNodeList");
            Object[] opFindEntryArgs = new Object[] {"4", "1", "1"};
            Class[] returnTypes = new Class[] { String.class }; 
            Object[] response = serviceClient.invokeBlocking(opFindEntry,
                    opFindEntryArgs, returnTypes);
    这个里面的"http://logic.kma.iip.com",地址是什么地址?
    还有我要response三个参数怎么接收?
      

  3.   

    QName是wsdl中定义的一个名字空间,webservices发布后,可以在wsdl中找到,一般都是发布类的包名称反写。
    opFindEntryArgs 定义的就是接口的输入参数,不管有多少个,都以对象数组的形式传送,
    {"4", "1", "1"}这里就是传递了三个字符串作为参数。至于接口的输出,肯定只能是只有一种类型。
      

  4.   

    谢谢你的支持.但我这还是有问题.发送不了.
    这是我的wsdl请帮忙看看.
    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions targetNamespace="urn:SPInterfaceServer" xmlns:impl="urn:SPInterfaceServer" xmlns:intf="urn:SPInterfaceServer" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <!--WSDL created by Apache Axis version: 1.2.1
    Built on Jun 14, 2005 (09:15:57 EDT)-->
     <wsdl:types>
      <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:SPInterfaceServer">
       <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
       <complexType name="AgentDRRequest">
        <sequence>
         <element name="comment" nillable="true" type="soapenc:string"/>
         <element name="contentName" nillable="true" type="soapenc:string"/>
         <element name="customerName" nillable="true" type="soapenc:string"/>
         <element name="extendParam" nillable="true" type="soapenc:string"/>
         <element name="icpCode" nillable="true" type="soapenc:string"/>
         <element name="productInfo" nillable="true" type="soapenc:string"/>
         <element name="spAccount" nillable="true" type="soapenc:string"/>
         <element name="userIp" nillable="true" type="soapenc:string"/>
        </sequence>
       </complexType>
       <complexType name="AgentDRResponse">
        <sequence>
         <element name="extendParam" nillable="true" type="soapenc:string"/>
         <element name="message" nillable="true" type="soapenc:string"/>
         <element name="returnCode" type="xsd:int"/>
        </sequence>
       </complexType>
      </schema>
     </wsdl:types>   <wsdl:message name="collectAgentDRRequest">      <wsdl:part name="in0" type="impl:AgentDRRequest"/>   </wsdl:message>   <wsdl:message name="collectAgentDRResponse">      <wsdl:part name="collectAgentDRReturn" type="impl:AgentDRResponse"/>   </wsdl:message>   <wsdl:portType name="SPInterfaceServer">      <wsdl:operation name="collectAgentDR" parameterOrder="in0">         <wsdl:input name="collectAgentDRRequest" message="impl:collectAgentDRRequest"/>         <wsdl:output name="collectAgentDRResponse" message="impl:collectAgentDRResponse"/>      </wsdl:operation>   </wsdl:portType>   <wsdl:binding name="SPInterfaceServerSoapBinding" type="impl:SPInterfaceServer">      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>      <wsdl:operation name="collectAgentDR">         <wsdlsoap:operation soapAction=""/>         <wsdl:input name="collectAgentDRRequest">            <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:SPInterfaceServer"/>         </wsdl:input>         <wsdl:output name="collectAgentDRResponse">            <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:SPInterfaceServer"/>         </wsdl:output>      </wsdl:operation>   </wsdl:binding>   <wsdl:service name="SPInterfaceServerService">      <wsdl:port name="SPInterfaceServer" binding="impl:SPInterfaceServerSoapBinding">         <wsdlsoap:address location=" http://localhost:8190/aaa/services/SPInterfaceServer"/>      </wsdl:port>   </wsdl:service></wsdl:definitions>