关于AXIS2 调用WCF的问题

ziming1019 2013-09-06 02:32:43
大家好,我使用AXIS2 调用WCF的时候遇到了如下的错误:
Exception in thread "main" org.apache.axis2.AxisFault: Must Understand check failed for header http://www.w3.org/2005/08/addressing : Action

我通过两种方法调用都是一样的错误,axis2的工具生成的方法以及手写的方法,手写的方法如下:
package ws;

import javax.xml.namespace.QName;

import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.addressing.RelatesTo;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;


public class WebServiceTest {

/**
* @param args
*/
public static void main(String[] args)throws AxisFault {
Object[] opAddEntryArgs = new Object[] {"100000260032","4832"};
// String url="http://r2-sv0038.connecteast.local/ETollingPortal2AbstractionServiceIVR/AccountBalance.svc?wsdl";
String url="http://r2-sv0038.connecteast.local/ETollingPortal2AbstractionServiceIVR/AccountBalance.svc";
//url="http://www.w3.org/2005/08/addressing/anonymous.";
String method="GetAccountBalance1";
WebServiceTest.sendService(opAddEntryArgs,url,method);
}
public static String sendService(Object[] opAddEntryArgs,String url,String method) throws AxisFault{
String xml=null;

RPCServiceClient serviceClient = new RPCServiceClient();
//serviceClient.engageModule(new javax.xml.namespace.QName( org.apache.axis2.Constants.MODULE_ADDRESSING ) );
Options options = serviceClient.getOptions();
//这里设置使用soap1.2,wcf用的是wshttpbinding 使用的也是soap1.2 貌似axis默认使用soap1.1。
//否则会报Exception in thread "main" org.apache.axis2.AxisFault: Transport error: 415 Error:
//Cannot process the message because the content type 'text/xml; charset=UTF-8'
//was not the expected type 'application/soap+xml; charset=utf-8'.的错误
options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);//

EndpointReference targetEPR = new EndpointReference(url);
options.setTo(targetEPR);
options.setTimeOutInMilliSeconds((long)600000);
//options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);

// 在创建QName对象时,QName类的构造方法的第一个参数表示WSDL文件的命名空间名,也就是<wsdl:definitions>元素的targetNamespace属性值
QName opAddEntry = new QName("http://tempuri.org/",method);
// 参数,如果有多个,继续往后面增加即可,不用指定参数的名称
////Object[] opAddEntryArgs = new Object[] {xmlStr};
// 返回参数类型,这个和axis1有点区别
// invokeBlocking方法有三个参数,其中第一个参数的类型是QName对象,表示要调用的方法名;
// 第二个参数表示要调用的WebService方法的参数值,参数类型为Object[];
// 第三个参数表示WebService方法的返回值类型的Class对象,参数类型为Class[]。
// 当方法没有参数时,invokeBlocking方法的第二个参数值不能是null,而要使用new Object[]{}
// 如果被调用的WebService方法没有返回值,应使用RPCServiceClient类的invokeRobust方法,
// 该方法只有两个参数,它们的含义与invokeBlocking方法的前两个参数的含义相同
Class[] classes = new Class[] { String.class };
xml=(String)serviceClient.invokeBlocking(opAddEntry,opAddEntryArgs, classes)[0];
System.out.println(xml);
return xml;
}


}

...全文
942 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
bingxpu 2014-08-25
  • 打赏
  • 举报
回复
你好 我也遇见了 相同的问题 TripPassServiceStub tpss=new TripPassServiceStub(); 这个是什么啊 能详细说一下吗
ziming1019 2013-10-22
  • 打赏
  • 举报
回复
引用 5 楼 u010795216 的回复:
我也遇到这这个错。请问你解决了嘛?
这之后还遇见很多问题,都忘了专门解决这个问题的办法了。最后好用的配置如下,需要在lib里添加addressing.mar的包

TripPassServiceStub tpss=new TripPassServiceStub();
			tpss._getServiceClient().engageModule("addressing");
			tpss._getServiceClient().getOptions().setProperty(AddressingConstants.WS_ADDRESSING_VERSION, org.apache.axis2.addressing.AddressingConstants.Final.WSA_NAMESPACE);
			int setWebServiceTimeOutInSeconds=mySession.getVariable(IProjectVariables.SET_WEB_SERVICE_TIME_OUT_IN_SECONDS).getSimpleVariable().getIntValue();
			tpss._getServiceClient().getOptions().setTimeOutInMilliSeconds(setWebServiceTimeOutInSeconds*1000);
			tpss._getServiceClient().getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT,true); 
			tpss._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, "false");//设置不受限制.
醒着做梦丶 2013-09-30
  • 打赏
  • 举报
回复
我也遇到这这个错。请问你解决了嘛?
ziming1019 2013-09-12
  • 打赏
  • 举报
回复
ziming1019 2013-09-09
  • 打赏
  • 举报
回复
webservice啊webservice,不是说跨平台么 你这是肿么了~~
ziming1019 2013-09-06
  • 打赏
  • 举报
回复
另外我在http://blogs.msdn.com/b/aszego/archive/2010/06/24/usernametoken-profile-vs-wcf.aspx 看到这样一段话 没太理解啊。。 Interoperability with Axis In the actual scenario I wrote this custom token for, the Java-based service didn’t like the addressing headers that WCF generated. In particular, the wsa:Action header had mustUnderstand set to true, and we got the error message that “Must Understand check failed for header http://www.w3.org/2005/08/addressing : Action”. WCF doesn’t allow removing mustUnderstand from the addressing headers (unless you remove it from the serialized message). Therefore, in the sample I simply ask WCF to not add the addressing headers by setting MessageVersion to Soap11.
YOLO系列是基于深度学习的端到端实时目标检测方法。 PyTorch版的YOLOv5轻量而性能高,更加灵活和易用,当前非常流行。 本课程将手把手地教大家使用labelImg标注和使用YOLOv5训练自己的数据集。课程实战分为两个项目:单目标检测(足球目标检测)和多目标检测(足球和梅西同时检测)。 本课程的YOLOv5使用ultralytics/yolov5,在Ubuntu系统上做项目演示。包括:安装YOLOv5、标注自己的数据集、准备自己的数据集、修改配置文件、训练自己的数据集、测试训练出的网络模型和性能统计。 希望学习在Windows系统上演示的学员,请前往《YOLOv5(PyTorch)实战:训练自己的数据集(Windows)》课程链接:https://edu.csdn.net/course/detail/30923本人推出了有关YOLOv5目标检测的系列课程。请持续关注该系列的其它视频课程,包括:《YOLOv5(PyTorch)目标检测实战:训练自己的数据集》Ubuntu系统 https://edu.csdn.net/course/detail/30793Windows系统 https://edu.csdn.net/course/detail/30923《YOLOv5(PyTorch)目标检测:原理与源码解析》课程链接:https://edu.csdn.net/course/detail/31428《YOLOv5目标检测实战:Flask Web部署》课程链接:https://edu.csdn.net/course/detail/31087《YOLOv5(PyTorch)目标检测实战:TensorRT加速部署》课程链接:https://edu.csdn.net/course/detail/32303《YOLOv5目标检测实战:Jetson Nano部署》课程链接:https://edu.csdn.net/course/detail/32451《YOLOv5+DeepSORT多目标跟踪与计数精讲》课程链接:https://edu.csdn.net/course/detail/32669《YOLOv5实战口罩佩戴检测》课程链接:https://edu.csdn.net/course/detail/32744《YOLOv5实战中国交通标志识别》课程链接:https://edu.csdn.net/course/detail/35209 《YOLOv5实战垃圾分类目标检测》课程链接:https://edu.csdn.net/course/detail/35284  

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧