简单的webservice 调用问题 顶的也给分

时间:2022-08-21 21:30:02
我用axis2 写的客户端     在本地部了个axis2的服务   调用成功

但是调用purl 写的服务端时 就报错  错误信息 如下:
org.apache.axis2.AxisFault: SOAPAction shall match 'uri#method' if present (got 'urn:calc', expected 'http://*.*.4.198:8000/CM_Toolkit/Example#calc'

at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:548)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
at org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:102)
at com.Axis2Client.askService(Axis2Client.java:97)
at com.Axis2Client.main(Axis2Client.java:21)

36 个解决方案

#1


purl服务的wsdl如下:
 <?xml version="1.0" encoding="UTF-8" ?> 
- <!--  WSDL for http://*.*.4.198:8000/cgi-bin/soap.pl created by Pod::WSDL version: 0.05 on Fri Dec  4 18:11:29 2009 
  --> 
- <wsdl:definitions targetNamespace="http://*.*.4.198:8000/CM_Toolkit/Example" xmlns:impl="http://*.*.4.198:8000/CM_Toolkit/Example" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns1="http://*.*.4.198:8000/CM_Toolkit/Example">
  <wsdl:message name="testRequest" /> 
- <wsdl:message name="testResponse">
  <wsdl:part name="testReturn" type="xsd:string" /> 
  </wsdl:message>
+ <wsdl:message name="calcRequest">
  <wsdl:part name="number1" type="xsd:int" /> 
  <wsdl:part name="string1" type="xsd:string" /> 
  <wsdl:part name="number2" type="xsd:int" /> 
  </wsdl:message>
- <wsdl:message name="calcResponse">
  <wsdl:part name="calcReturn" type="xsd:string" /> 
  </wsdl:message>
+ <wsdl:portType name="CM_ToolkitExampleHandler">
- <wsdl:operation name="test" parameterOrder="">
  <wsdl:documentation>获取web services 测试信息</wsdl:documentation> 
  <wsdl:input message="impl:testRequest" name="testRequest" /> 
  <wsdl:output message="impl:testResponse" name="testResponse" /> 
  </wsdl:operation>
- <wsdl:operation name="calc" parameterOrder="number1 string1 number2">
  <wsdl:documentation>根据传入的数字和数学计算符进行计算,返回计算结果</wsdl:documentation> 
  <wsdl:input message="impl:calcRequest" name="calcRequest" /> 
  <wsdl:output message="impl:calcResponse" name="calcResponse" /> 
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="CM_ToolkitExampleSoapBinding" type="impl:CM_ToolkitExampleHandler">
  <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> 
- <wsdl:operation name="test">
  <wsdlsoap:operation soapAction="" /> 
- <wsdl:input name="testRequest">
  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://*.*.4.198:8000/CM_Toolkit/Example" use="encoded" /> 
  </wsdl:input>
- <wsdl:output name="testResponse">
  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://*.*.4.198:8000/CM_Toolkit/Example" use="encoded" /> 
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="calc">
  <wsdlsoap:operation soapAction="" /> 
- <wsdl:input name="calcRequest">
  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://*.*.4.198:8000/CM_Toolkit/Example" use="encoded" /> 
  </wsdl:input>
- <wsdl:output name="calcResponse">
  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://*.*.4.198:8000/CM_Toolkit/Example" use="encoded" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="CM_ToolkitExampleHandlerService">
- <wsdl:port binding="impl:CM_ToolkitExampleSoapBinding" name="CM_ToolkitExample">
  <wsdlsoap:address location="http://*.*.4.198:8000/cgi-bin/soap.pl" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>

#2


我的客户端源码 :
import javax.xml.namespace.QName;

import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
import org.apache.axis2.transport.http.HTTPConstants;

/**
 * 测试
 * 
 * @author lujc
 * 
 */
public class Axis2Client {
    public static void main(String[] args) {
        Axis2Client axis2Client = new Axis2Client();
       try {
Object[] obj = axis2Client.askService("http://×.×.4.198:8000/cgi-bin/soap.pl",
"http://*.*.4.198:8000/CM_Toolkit/Example",
   "calc",new Object[]{1,"+",2}, new Class[]{String.class});

System.out.println("sssssssssssss"+obj[0]);

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
    }

public Object[] askService(String serviceUrl , String nameSpace , String strMethod ,Object[] params ,Class[] classess) throws Exception{

QName qname = new QName(nameSpace, strMethod);

//传递的参数对象集 
Object[] param = params; 
//结果集
Object[] element = null;
 
//实例化远程服务调用客户端对象 
RPCServiceClient client = new RPCServiceClient(); 
//实例化Options对象 
Options options = new Options(); 
//设置Options对象的连接终端地址 
options.setTo(new EndpointReference(serviceUrl)); 
//设置Options对象的操作事件对象 
options.setAction("urn:"+strMethod); 
options.setProperty(HTTPConstants.CHUNKED, "false");//设置不受限制.
//为远程服务调用客户端对象设置Options子对象 
client.setOptions(options); 
//传递参数,调用服务,获取服务返回结果集 
Class[] classes = classess;
element = client.invokeBlocking(qname, param ,classes); 
//获取返回结果集中第一条结果的返回内容 
//字符串转换为整型 
//sum= Integer.parseInt(result);  
// } 
// //捕捉异常 
// catch (AxisFault e) { 
// throw e;
// //e.printStackTrace(); 
// } 
//返回内容 

return element;
}
}


分数忘改了   本帖 200分  另开帖给分

#3


帮顶一个,散分的时候别忘了我啊,嘿嘿

#4


不了解..只能帮你顶..

#5


本人还没到这步 ...帮顶了

#6


不好意思  单词写错了  不是purl  是perl

#7


自己顶

#8


简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分

#9


顶一个

http://topic.csdn.net/u/20091125/16/2e8bf8ec-8390-4dcf-bc27-b8398696a634.html 向大家推荐几本好书!! 软件工程方面的

http://topic.csdn.net/u/20091202/16/c3242b3f-b702-43a8-b6c8-6b11ab48a3c0.html?seed=1801029888&r=61644641#r_61644641 2009互联网大会交流--网易内部培训资料

http://download.csdn.net/source/1872742 2009年移动面对电信的应对策略
http://download.csdn.net/source/1872730 3G基础学习资料--通俗易懂

#10


我再顶

#11


顶顶顶

#12


自己顶

#13


进来支持一下!

#14


mark

#15


看来大家都很忙啊

#16


帖子要沉

#17


got 'urn:calc', expected 'http://*.*.4.198:8000/CM_Toolkit/Example#calc'


//设置Options对象的操作事件对象 
        options.setAction("urn:"+strMethod); 


是不是urn:calc要改成Example#calc

#18


你的WSDL我拿下来解析有问题

#19


引用 17 楼 believefym 的回复:
[Quote=]
got 'urn:calc', expected 'http://*.*.4.198:8000/CM_Toolkit/Example#calc'

Java code//设置Options对象的操作事件对象        options.setAction("urn:"+strMethod);


是不是urn:calc要改成Example#calc


[/Quote]

我试了
好像不是   

#20


引用 18 楼 szlb2008 的回复:
你的WSDL我拿下来解析有问题


然后呢   什么地方有问题?

#21


顶下`````

#22


#23


不懂 帮顶

#24


起来

#25


顶起来,楼主给分,快给分

#26


引用 5 楼 hsw1997 的回复:
本人还没到这步 ...帮顶了


呵呵  帮顶 JF

#27


我也来看看,刚刚弄了一下webservice 还不是很熟悉

#28


webservice 到底是啥东西啊

#29


我顶算哒...
jf

#30


帮顶吧 

#31


不懂,还是接点分算了!

#32


不懂,帮顶,JF

#33


继续顶啊

#34


...up

#35


  不懂,学习,帮顶

#36


马老大 都帮顶了

#1


purl服务的wsdl如下:
 <?xml version="1.0" encoding="UTF-8" ?> 
- <!--  WSDL for http://*.*.4.198:8000/cgi-bin/soap.pl created by Pod::WSDL version: 0.05 on Fri Dec  4 18:11:29 2009 
  --> 
- <wsdl:definitions targetNamespace="http://*.*.4.198:8000/CM_Toolkit/Example" xmlns:impl="http://*.*.4.198:8000/CM_Toolkit/Example" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns1="http://*.*.4.198:8000/CM_Toolkit/Example">
  <wsdl:message name="testRequest" /> 
- <wsdl:message name="testResponse">
  <wsdl:part name="testReturn" type="xsd:string" /> 
  </wsdl:message>
+ <wsdl:message name="calcRequest">
  <wsdl:part name="number1" type="xsd:int" /> 
  <wsdl:part name="string1" type="xsd:string" /> 
  <wsdl:part name="number2" type="xsd:int" /> 
  </wsdl:message>
- <wsdl:message name="calcResponse">
  <wsdl:part name="calcReturn" type="xsd:string" /> 
  </wsdl:message>
+ <wsdl:portType name="CM_ToolkitExampleHandler">
- <wsdl:operation name="test" parameterOrder="">
  <wsdl:documentation>获取web services 测试信息</wsdl:documentation> 
  <wsdl:input message="impl:testRequest" name="testRequest" /> 
  <wsdl:output message="impl:testResponse" name="testResponse" /> 
  </wsdl:operation>
- <wsdl:operation name="calc" parameterOrder="number1 string1 number2">
  <wsdl:documentation>根据传入的数字和数学计算符进行计算,返回计算结果</wsdl:documentation> 
  <wsdl:input message="impl:calcRequest" name="calcRequest" /> 
  <wsdl:output message="impl:calcResponse" name="calcResponse" /> 
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="CM_ToolkitExampleSoapBinding" type="impl:CM_ToolkitExampleHandler">
  <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> 
- <wsdl:operation name="test">
  <wsdlsoap:operation soapAction="" /> 
- <wsdl:input name="testRequest">
  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://*.*.4.198:8000/CM_Toolkit/Example" use="encoded" /> 
  </wsdl:input>
- <wsdl:output name="testResponse">
  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://*.*.4.198:8000/CM_Toolkit/Example" use="encoded" /> 
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="calc">
  <wsdlsoap:operation soapAction="" /> 
- <wsdl:input name="calcRequest">
  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://*.*.4.198:8000/CM_Toolkit/Example" use="encoded" /> 
  </wsdl:input>
- <wsdl:output name="calcResponse">
  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://*.*.4.198:8000/CM_Toolkit/Example" use="encoded" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="CM_ToolkitExampleHandlerService">
- <wsdl:port binding="impl:CM_ToolkitExampleSoapBinding" name="CM_ToolkitExample">
  <wsdlsoap:address location="http://*.*.4.198:8000/cgi-bin/soap.pl" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>

#2


我的客户端源码 :
import javax.xml.namespace.QName;

import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
import org.apache.axis2.transport.http.HTTPConstants;

/**
 * 测试
 * 
 * @author lujc
 * 
 */
public class Axis2Client {
    public static void main(String[] args) {
        Axis2Client axis2Client = new Axis2Client();
       try {
Object[] obj = axis2Client.askService("http://×.×.4.198:8000/cgi-bin/soap.pl",
"http://*.*.4.198:8000/CM_Toolkit/Example",
   "calc",new Object[]{1,"+",2}, new Class[]{String.class});

System.out.println("sssssssssssss"+obj[0]);

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
    }

public Object[] askService(String serviceUrl , String nameSpace , String strMethod ,Object[] params ,Class[] classess) throws Exception{

QName qname = new QName(nameSpace, strMethod);

//传递的参数对象集 
Object[] param = params; 
//结果集
Object[] element = null;
 
//实例化远程服务调用客户端对象 
RPCServiceClient client = new RPCServiceClient(); 
//实例化Options对象 
Options options = new Options(); 
//设置Options对象的连接终端地址 
options.setTo(new EndpointReference(serviceUrl)); 
//设置Options对象的操作事件对象 
options.setAction("urn:"+strMethod); 
options.setProperty(HTTPConstants.CHUNKED, "false");//设置不受限制.
//为远程服务调用客户端对象设置Options子对象 
client.setOptions(options); 
//传递参数,调用服务,获取服务返回结果集 
Class[] classes = classess;
element = client.invokeBlocking(qname, param ,classes); 
//获取返回结果集中第一条结果的返回内容 
//字符串转换为整型 
//sum= Integer.parseInt(result);  
// } 
// //捕捉异常 
// catch (AxisFault e) { 
// throw e;
// //e.printStackTrace(); 
// } 
//返回内容 

return element;
}
}


分数忘改了   本帖 200分  另开帖给分

#3


帮顶一个,散分的时候别忘了我啊,嘿嘿

#4


不了解..只能帮你顶..

#5


本人还没到这步 ...帮顶了

#6


不好意思  单词写错了  不是purl  是perl

#7


自己顶

#8


简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分
简单的webservice 调用问题 顶的也给分

#9


顶一个

http://topic.csdn.net/u/20091125/16/2e8bf8ec-8390-4dcf-bc27-b8398696a634.html 向大家推荐几本好书!! 软件工程方面的

http://topic.csdn.net/u/20091202/16/c3242b3f-b702-43a8-b6c8-6b11ab48a3c0.html?seed=1801029888&r=61644641#r_61644641 2009互联网大会交流--网易内部培训资料

http://download.csdn.net/source/1872742 2009年移动面对电信的应对策略
http://download.csdn.net/source/1872730 3G基础学习资料--通俗易懂

#10


我再顶

#11


顶顶顶

#12


自己顶

#13


进来支持一下!

#14


mark

#15


看来大家都很忙啊

#16


帖子要沉

#17


got 'urn:calc', expected 'http://*.*.4.198:8000/CM_Toolkit/Example#calc'


//设置Options对象的操作事件对象 
        options.setAction("urn:"+strMethod); 


是不是urn:calc要改成Example#calc

#18


你的WSDL我拿下来解析有问题

#19


引用 17 楼 believefym 的回复:
[Quote=]
got 'urn:calc', expected 'http://*.*.4.198:8000/CM_Toolkit/Example#calc'

Java code//设置Options对象的操作事件对象        options.setAction("urn:"+strMethod);


是不是urn:calc要改成Example#calc


[/Quote]

我试了
好像不是   

#20


引用 18 楼 szlb2008 的回复:
你的WSDL我拿下来解析有问题


然后呢   什么地方有问题?

#21


顶下`````

#22


#23


不懂 帮顶

#24


起来

#25


顶起来,楼主给分,快给分

#26


引用 5 楼 hsw1997 的回复:
本人还没到这步 ...帮顶了


呵呵  帮顶 JF

#27


我也来看看,刚刚弄了一下webservice 还不是很熟悉

#28


webservice 到底是啥东西啊

#29


我顶算哒...
jf

#30


帮顶吧 

#31


不懂,还是接点分算了!

#32


不懂,帮顶,JF

#33


继续顶啊

#34


...up

#35


  不懂,学习,帮顶

#36


马老大 都帮顶了