从Java调用Web服务"带有Action''不能在接收器处理"

时间:2015-07-27 12:04:08

标签: java web-services soap

我是网络服务和java的新手,所以我的一些问题是将我的应用程序与外部Web服务连接起来。我总是得到这个例外

  

带有操作的消息''无法在接收器处理

也许我的假设是错误的,但我认为该操作是在SOAP有效负载内定义的。这是WSDL:

<?xml version='1.0'?>
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.tempuri.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.tempuri.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types />
  <message name="BINICIARREPORTRequest">
    <part name="EAUSUARIO" type="xsd:string" />
    <part name="EAMODULO" type="xsd:string" />
    <part name="EANOMREPOR" type="xsd:string" />
    <part name="EAPARAMREPOR" type="xsd:string" />
    <part name="EANOMPANTA" type="xsd:string" />
  </message>
  <message name="BINICIARREPORTResponse">
    <part name="RESULT" type="xsd:boolean" />
  </message>
  <portType name="PWS_LANZA_REPOR_PORT_1">
    <operation name="BINICIARREPORT">
      <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
      <input message="tns:BINICIARREPORTRequest" />
      <output message="tns:BINICIARREPORTResponse" />
    </operation>
  </portType>
  <binding name="PWS_LANZA_REPOR_PORT_1Soap" type="tns:PWS_LANZA_REPOR_PORT_1">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
    <operation name="BINICIARREPORT">
      <soap:operation soapAction="http://www.tempuri.org/wsdl/BINICIARREPORTRequest" style="rpc" />
      <input name="BINICIARREPORTRequest">
        <soap:body use="encoded" namespace="http://www.tempuri.org/wsdl/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </input>
      <output name="BINICIARREPORTResponse">
        <soap:body use="encoded" namespace="http://www.tempuri.org/wsdl/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </output>
    </operation>
  </binding>
  <service name="PWS_LANZA_REPOR">
    <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
    <port name="PWS_LANZA_REPOR_PORT_1Port" binding="tns:PWS_LANZA_REPOR_PORT_1Soap">
      <soap:address location="" />
    </port>
  </service>
</definitions>

以下是我使用的代码:

        final String endpointUrl = this.configuracion
                .getConfigJNDI(WS_MECANIZACION_JNDI);

        final QName serviceName = new QName(null,
                "PWS_LANZA_REPOR");
        final QName portName = new QName(null, "PWS_LANZA_REPOR_PORT_1Port");
        final javax.xml.ws.Service service = javax.xml.ws.Service
                .create(serviceName);
        service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING,
                endpointUrl);

        final Dispatch<SOAPMessage> dispatch = service.createDispatch(
                portName, SOAPMessage.class,
                javax.xml.ws.Service.Mode.MESSAGE);

        final SOAPMessage response = dispatch.invoke(mensajeSOAP);

如果我使用SoapUI来检查这一点,一切正常(消息没问题,以及endpointURL),但是java应用程序没有任何成功。

这是我发送的肥皂信息:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="s" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
        <wsdl:BINICIARREPORT xmlns:wsdl="cosa">
            <EAUSUARIO>CD</EAUSUARIO>
            <EAMODULO>PR</EAMODULO>
            <EANOMREPOR>PRR14</EANOMREPOR>
            <EAPARAMREPOR/>
            <EANOMPANTA/>
        </wsdl:BINICIARREPORT>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

我不知道这是否重要,但我得到的网址没有&#34;?wsdl&#34;在那时结束:

  

http://prueba/prueba/Pws_Lanza_Rep1.svc

任何线索?

1 个答案:

答案 0 :(得分:0)

我还没想出来,但按照步骤here一切正常! 我使用了相同的xml和相同的参数,所以我仍然觉得为什么以前的代码不起作用。