轴网络服务中的“无此操作”错误

时间:2010-10-06 17:36:01

标签: java web-services axis

我正在使用两种方法开发一个轴java Web服务,它们都有一个自定义Object作为参数,一个自定义对象作为返回值。我把它们在wsdd中定义为:

 <service name="MyService" provider="java:RPC" style="document" use="literal">
        <parameter name="className" value="com.mycompany.webservice.MyService"/>
        <parameter name="allowedMethods" value="*"/>
        <parameter name="scope" value="Application"/>
        <beanMapping qname="ns:GetDataRequest" xmlns:ns="GetDataRequest"  languageSpecificType="java:com.mycompany.bo.webservice.request.GetDataRequest"/>
        <beanMapping qname="ns:AuthenticateRequest" xmlns:ns="AuthenticateRequest"  languageSpecificType="java:com.mycompany.bo.webservice.request.AuthenticateRequest"/>
        <beanMapping qname="ns:GetData" xmlns:ns="GetData"  languageSpecificType="java:com.mycompany.bo.webservice.response.GetData"/>
        <beanMapping qname="ns:Authenticate" xmlns:ns="Authenticate"  languageSpecificType="java:com.mycompany.bo.webservice.response.Authenticate"/>
        <namespace>http://com.mycompany.webservice</namespace>
    </service>

当我在客户端执行“Authenticate”方法时,一切都很完美。但是,当我从客户端执行“GetData”时,我对“正在进行的操作”有任何想法吗?

我在服务器中尝试了两种具有相同参数的方法,一切顺利。感谢

更新:我已尝试将服务样式/用法从文档/文字更改为包装,现在我在两种方法上都出现相同的错误

更新:生成的wsdl为:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://com.mycompany.webservice" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://com.mycompany.webservice" xmlns:intf="http://com.mycompany.webservice" xmlns:tns1="AuthenticateRequest" xmlns:tns2="Authenticate" xmlns:tns3="http://response.webservice.bo.myCompany.com" xmlns:tns4="GetDataRequest" xmlns:tns5="GetData" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
 <wsdl:types>
  <schema elementFormDefault="qualified" targetNamespace="AuthenticateRequest" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="Authenticate"/>
   <import namespace="GetDataRequest"/>
   <import namespace="GetData"/>
   <import namespace="http://response.webservice.bo.myCompany.com"/>
   <complexType name="AuthenticateRequest">

    <sequence>
     <element name="contra" nillable="true" type="xsd:string"/>
     <element name="user" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
  </schema>
  <schema elementFormDefault="qualified" targetNamespace="http://com.mycompany.webservice" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="Authenticate"/>
   <import namespace="GetDataRequest"/>

   <import namespace="GetData"/>
   <import namespace="http://response.webservice.bo.myCompany.com"/>
   <import namespace="AuthenticateRequest"/>
   <element name="peticion" type="tns1:AuthenticateRequest"/>
   <element name="authenticateReturn" type="tns2:Authenticate"/>
   <element name="peticion1" type="tns4:GetDataRequest"/>
   <element name="getDataReturn" type="tns5:GetData"/>
  </schema>
  <schema elementFormDefault="qualified" targetNamespace="http://response.webservice.bo.myCompany.com" xmlns="http://www.w3.org/2001/XMLSchema">

   <import namespace="Authenticate"/>
   <import namespace="GetDataRequest"/>
   <import namespace="GetData"/>
   <import namespace="AuthenticateRequest"/>
   <complexType name="WSResponse">
    <sequence>
     <element name="codigo" nillable="true" type="xsd:string"/>
     <element name="comentario" nillable="true" type="xsd:string"/>
    </sequence>

   </complexType>
  </schema>
  <schema elementFormDefault="qualified" targetNamespace="Authenticate" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="GetDataRequest"/>
   <import namespace="GetData"/>
   <import namespace="http://response.webservice.bo.myCompany.com"/>
   <import namespace="AuthenticateRequest"/>
   <complexType name="Authenticate">
    <complexContent>

     <extension base="tns3:WSResponse">
      <sequence>
       <element name="idSession" nillable="true" type="xsd:string"/>
      </sequence>
     </extension>
    </complexContent>
   </complexType>
  </schema>
  <schema elementFormDefault="qualified" targetNamespace="GetDataRequest" xmlns="http://www.w3.org/2001/XMLSchema">

   <import namespace="Authenticate"/>
   <import namespace="GetData"/>
   <import namespace="http://response.webservice.bo.myCompany.com"/>
   <import namespace="AuthenticateRequest"/>
   <complexType name="GetDataRequest">
    <sequence>
     <element name="idSession" nillable="true" type="xsd:string"/>
     <element name="poblacion" nillable="true" type="xsd:string"/>
     <element name="provincia" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
  </schema>
  <schema elementFormDefault="qualified" targetNamespace="GetData" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="Authenticate"/>
   <import namespace="GetDataRequest"/>
   <import namespace="http://response.webservice.bo.myCompany.com"/>
   <import namespace="AuthenticateRequest"/>
   <complexType name="GetData">

    <complexContent>
     <extension base="tns3:WSResponse">
      <sequence>
       <element name="provincia" nillable="true" type="xsd:string"/>
       <element name="poblacion" nillable="true" type="xsd:string"/>
       <element name="cp" nillable="true" type="xsd:string"/>
       <element name="dato" type="xsd:double"/>
       <element name="cuantos" type="xsd:int"/>
      </sequence>
     </extension>
    </complexContent>
   </complexType>
  </schema>

 </wsdl:types>

   <wsdl:message name="getDataResponse">
      <wsdl:part element="impl:getDataReturn" name="getDataReturn"/>
   </wsdl:message>

   <wsdl:message name="authenticateRequest">
      <wsdl:part element="impl:peticion" name="peticion"/>
   </wsdl:message>

   <wsdl:message name="getDataRequest">
      <wsdl:part element="impl:peticion1" name="peticion"/>
   </wsdl:message>

   <wsdl:message name="authenticateResponse">
      <wsdl:part element="impl:authenticateReturn" name="authenticateReturn"/>
   </wsdl:message>

   <wsdl:portType name="MyService">
      <wsdl:operation name="authenticate" parameterOrder="peticion">
         <wsdl:input message="impl:authenticateRequest" name="authenticateRequest"/>
         <wsdl:output message="impl:authenticateResponse" name="authenticateResponse"/>
      </wsdl:operation>

      <wsdl:operation name="getData" parameterOrder="peticion">
         <wsdl:input message="impl:getDataRequest" name="getDataRequest"/>
         <wsdl:output message="impl:getDataResponse" name="getDataResponse"/>
      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="MyServiceSoapBinding" type="impl:MyService">

      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="authenticate">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="authenticateRequest">
            <wsdlsoap:body use="literal"/>
         </wsdl:input>

         <wsdl:output name="authenticateResponse">
            <wsdlsoap:body use="literal"/>
         </wsdl:output>
      </wsdl:operation>

      <wsdl:operation name="getData">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="getDataRequest">
            <wsdlsoap:body use="literal"/>
         </wsdl:input>

         <wsdl:output name="getDataResponse">
            <wsdlsoap:body use="literal"/>
         </wsdl:output>
      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="MyServiceService">
      <wsdl:port binding="impl:MyServiceSoapBinding" name="MyService">
         <wsdlsoap:address location="http://www.localhost.com:8080/myWS/services/MyService"/>
      </wsdl:port>
   </wsdl:service>

</wsdl:definitions>

错误代码是:

No such operation 'peticion1'
    org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
    org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
    org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
    com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2938)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
    com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
    com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
    com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
    com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
    com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
    org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
    org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
    org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
    org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    org.apache.axis.client.Call.invoke(Call.java:2767)
    org.apache.axis.client.Call.invoke(Call.java:2443)
    org.apache.axis.client.Call.invoke(Call.java:2366)
    org.apache.axis.client.Call.invoke(Call.java:1812)
    example.MyServiceSoapBindingStub.getData(MyServiceSoapBindingStub.java:230)

2 个答案:

答案 0 :(得分:2)

我在很多其他论坛上都看到过这个问题而根本没有回复。它似乎是Axis 1.x中的一个问题,所以最后我改为另一个SOAP堆栈(在我的例子中是Axis2)。一切正常。

答案 1 :(得分:1)

好吧,我希望回答这个话题的时间不会太晚,我在几个小时前遇到了这个错误,结果是如果你为轴生成一个Java客户端,例如使用eclipse。这产生了几个clases,在clases中生成一个* BindingStub;在这个类中创建了一个名为&#34; createCall()&#34;的方法,这个方法非常重要,因为这里是自动生成的代码,用于设置类型映射到调用,并且这个Axis知道映射从客户端到服务的请求参数。

我已将此逻辑实现到Array类型的Request Parameter。错误已经消失。

Service service = new Service();
    Call _call = (Call) service.createCall();
    //
    synchronized (this) {
        Class<?> clazz = co.development.portals.ws.model.PointSoap[].class;
        QName arrayQName = new QName(
                "urn:http.service.ws.portals.development.co", 
                "ArrayOf_tns2_PointSoap"), 
                objectQName = new QName(
                        "http://model.ws.portals.development.co", 
                        "PointSoap");;
        SerializerFactory serializerFactory = (SerializerFactory)
                new ArraySerializerFactory(objectQName, null);
        DeserializerFactory deserializerFactory = (DeserializerFactory) 
                new ArrayDeserializerFactory();
        _call.registerTypeMapping(
                clazz, 
                arrayQName, 
                serializerFactory, 
                deserializerFactory, 
                false);
    } ..... Other stuff like setting Endpoint, operation, returnType and so on to the _call object.

的确,我的服务收到了PointSoap数组。

注意:对不起我的英语Jejeje。

最诚挚的问候, 哈维