«Нет такой операции» Ошибка в оси веб-сервиса - PullRequest
1 голос
/ 06 октября 2010

Я разрабатываю веб-сервис Java-оси с двумя методами, оба из которых имеют пользовательский объект в качестве параметра и пользовательский объект в качестве возвращаемого значения.Я определил их в 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>

Когда я выполняю на клиенте метод «Аутентификация», все работает идеально.Но когда я выполняю с клиента «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 ]

2 голосов
/ 15 октября 2010

Я видел проблему на многих других форумах и вообще ни одного ответа. Кажется, это проблема в Axis 1.x, поэтому, наконец, я перехожу на другой стек SOAP (Axis2 в моем случае). И все работает.

1 голос
/ 10 августа 2017

Что ж, я надеюсь, что еще не так поздно ответить на эту тему, я столкнулся с этой ошибкой несколько часов назад, и в результате получается, что если вы генерируете Java-клиент для оси, например, с помощью eclipse. Это генерирует несколько предложений, в которых создаются a * BindingStub; в этом классе создается метод с именем «createCall ()», этот метод довольно важен, потому что здесь автоматически генерируется код, который устанавливает сопоставление типов для вызова, и с этим Axis знает, как отображать параметры запроса от клиента к услуге.

Я реализовал эту логику в параметре запроса типа Array. И ошибка ушла.

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.

С наилучшими пожеланиями, Harvey

...