Axis2异常org.apache.axis2.AxisFault:使用存根的字符串

时间:2012-02-26 22:31:41

标签: web-services axis2

我正在尝试创建一个WS,在Tomcat中部署它,在Web应用程序内部并使用存根来调用它。

我正在使用此接口作为WSDL的基础:

package com.at.iscrizio.ws.services;
public interface SalutareService {
  public String sayciao(String name);    
}

和这个脚本生成wsdl文件,服务器和部署文件以及客户端文件:

set WSDL_FILE=SalutareService.wsdl
set TO_WSDL=%AXIS2_HOME%/bin/java2wsdl.bat
set TO_JAVA=%AXIS2_HOME%/bin/wsdl2java.bat
set CLASS=com.at.iscrizio.ws.services.SalutareService
set SOAP_ADDR=http://localhost:9090/Iscrizio/services/SalutareServiceEx

call %TO_WSDL% -cp build/classes -o ./wsdl -of %WSDL_FILE% -cn %CLASS% -l %SOAP_ADDR%
call %TO_JAVA% -uri wsdl/%WSDL_FILE% -S generated -o axis -ss -sd -ssi --noWSDL
call %TO_JAVA% -uri wsdl/%WSDL_FILE% -S generated -o axis

这是我的WS实现

package com.at.iscrizio.ws.services;
public class SalutareServiceEx implements SalutareServiceSkeletonInterface {
  @Override
  public SayciaoResponse sayciao(Sayciao sayciao) {
    SayciaoResponse resp = new SayciaoResponse();
    resp.set_return("Ciao");
    return resp;
  }
}

这是我的service.xml(与标准轴build.xml生成的有点不同,只是为了更改ServiceClass):

<?xml version="1.0" encoding="UTF-8"?>
<!-- This file was auto-generated from WSDL -->
<!-- by the Apache Axis2 version: 1.6.1  Built on : Aug 31, 2011 (12:22:40 CEST) -->
<serviceGroup>
    <service name="SalutareServiceEx">
        <messageReceivers>
            <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"     class="com.at.iscrizio.ws.services.SalutareServiceMessageReceiverInOut"/>
        </messageReceivers>
        <parameter   name="ServiceClass">com.at.iscrizio.ws.services.SalutareServiceEx</parameter>
        <parameter name="useOriginalwsdl">true</parameter>
        <parameter name="modifyUserWSDLPortAddress">true</parameter>
        <operation name="sayciao" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://services.ws.iscrizio.at.com">
            <actionMapping>urn:sayciao</actionMapping>
            <outputActionMapping>urn:sayciaoResponse</outputActionMapping>
       </operation>
    </service>
</serviceGroup>

在server-config.wsdd中,我有:

  <handler name="Trace" type="java:com.at.iscrizio.ws.handler.TraceHandler"/>
  <service name="SalutareServiceEx" provider="java:RPC">
  <requestFlow>
    <handler type="Trace"/>
  </requestFlow>
  <parameter name="allowedMethods" value="sayciao"/>
  <parameter name="scope" value="Request"/>
  <parameter name="className" value="com.at.iscrizio.ws.services.SalutareServiceEx"/>
</service>

我可以看到页面http://localhost:9090/Iscrizio/services/SalutareServiceEx?wsdl

我们快要结束......用这段代码,我用stub来调用ws:

SalutareServiceStub stub = new SalutareServiceStub(); 
SalutareServiceStub.Sayciao param = new SalutareServiceStub.Sayciao();
param.setName("Antonio");
SalutareServiceStub.SayciaoResponse resp = stub.sayciao(param);
System.out.println(resp);

请求通过我的处理程序(在wsdd中定义的那个),我可以看到使用远程调试。 使用TCPMon,我看到了我的请求:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Body>
    <ns1:sayciao xmlns:ns1="http://services.ws.iscrizio.at.com">
      <ns1:name>Antonio</ns1:name>
    </ns1:sayciao>
  </soapenv:Body>
</soapenv:Envelope>

和ws回复:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"     xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-    instance">
<soapenv:Body>
  <soapenv:Fault>
    <soapenv:Code>
      <soapenv:Value>soapenv:Sender</soapenv:Value>
        <soapenv:Subcode xmlns:ns1="http://www.w3.org/2003/05/soap-rpc">
          <soapenv:Value>ns1:BadArguments</soapenv:Value>
        </soapenv:Subcode>
    </soapenv:Code>
    <soapenv:Reason>
      <soapenv:Text xml:lang="en">string</soapenv:Text>
    </soapenv:Reason>
    <soapenv:Detail>
      <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">anto-note</ns2:hostname>
    </soapenv:Detail>
  </soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

这是堆栈跟踪:

Exception in thread "main" org.apache.axis2.AxisFault: string
    at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
    at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at com.at.iscrizio.ws.services.SalutareServiceStub.sayciao(SalutareServiceStub.java:185)
    at com.at.iscrizio.ws.client.TestClient.main(TestClient.java:25)

问题出在哪里?请原谅我这个巨大的帖子,感谢所有

1 个答案:

答案 0 :(得分:0)

至少你知道服务器端有问题。 soapui产生的要求与您的orig请求不同?听起来很奇怪但是肥皂通常是正确的。我个人会调试服务器端并尝试找出它出错的地方,例如设置一些异常断点