axis2的405 Error: Method Not Allowed问题

zh919919 2013-07-11 03:43:01
第一次玩AXIS2,试过2种方式,一种是普通调用,一种是RPC调用,结果都一样。看了下代码也没发现访问方法有什么错误。错误代码如下:
org.apache.axis2.AxisFault: Transport error: 405 Error: Method Not Allowed
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:310)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSendr.java:194)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:555)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:531)

...全文
889 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
zh919919 2013-08-06
  • 打赏
  • 举报
回复
引用 10 楼 fangmingshijie 的回复:
加上auth.setPreemptiveAuthentication(true);看下
加上这个还是不行,不过现在已经用CXF实现了。感谢帮助
  • 打赏
  • 举报
回复
加上auth.setPreemptiveAuthentication(true);看下
  • 打赏
  • 举报
回复
引用 7 楼 zh919919 的回复:
[quote=引用 6 楼 fangmingshijie 的回复:] 应该是你的参数中有中文乱码引起的,看看是否有中文参数。
参数里面没有任何中文,全是数字和字母。为了确保不是参数问题我将所有参数置为空依然出现这个错误。 不过刚刚意外的发现我写的权限验证并没有起作用,难道是这个引起的?

HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();         
auth.setUsername(USER_NAME);         
auth.setPassword(USER_PWD);           
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth); 
[/quote] 应该有影响。
zh919919 2013-07-16
  • 打赏
  • 举报
回复
引用 6 楼 fangmingshijie 的回复:
应该是你的参数中有中文乱码引起的,看看是否有中文参数。
参数里面没有任何中文,全是数字和字母。为了确保不是参数问题我将所有参数置为空依然出现这个错误。 不过刚刚意外的发现我写的权限验证并没有起作用,难道是这个引起的?

HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();         
auth.setUsername(USER_NAME);         
auth.setPassword(USER_PWD);           
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth); 
zh919919 2013-07-16
  • 打赏
  • 举报
回复
引用 8 楼 fangmingshijie 的回复:
[quote=引用 7 楼 zh919919 的回复:] [quote=引用 6 楼 fangmingshijie 的回复:] 应该是你的参数中有中文乱码引起的,看看是否有中文参数。
参数里面没有任何中文,全是数字和字母。为了确保不是参数问题我将所有参数置为空依然出现这个错误。 不过刚刚意外的发现我写的权限验证并没有起作用,难道是这个引起的?

HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();         
auth.setUsername(USER_NAME);         
auth.setPassword(USER_PWD);           
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth); 
[/quote] 应该有影响。[/quote] 这种写法是参照官网的API写的,刚刚试了直接写到header里传过去也无效。现在准备用CXF试试。
  • 打赏
  • 举报
回复
应该是你的参数中有中文乱码引起的,看看是否有中文参数。
zh919919 2013-07-15
  • 打赏
  • 举报
回复
没人会么?看来要换个技术调用了
oh_Maxy 2013-07-11
  • 打赏
  • 举报
回复
我玩的是axis1.4 wsdd形式发布服务。 里面有一个allowedmethod节点,会列出所有允许的服务。不晓得Axis2有没有类似的东东
zh919919 2013-07-11
  • 打赏
  • 举报
回复
这都要下班了也没个大神出现么?
zh919919 2013-07-11
  • 打赏
  • 举报
回复
以上是代码,求大神出现。
zh919919 2013-07-11
  • 打赏
  • 举报
回复

private static final String url = "接口地址";
	
private static final String QNAME_URL = "命名空间";
	
private static final String USER_NAME = "账号";
	
private static final String USER_PWD = "密码";

public static void ServiceClient(){
		try {
			ServiceClient client = new ServiceClient();
			
			client.setOptions(buildOptions());

			OMElement element = client.sendReceive(buildParam());
			
			Iterator it = element.getChildElements();
			
			while(it.hasNext()){
				OMElement omElement = (OMElement) it.next();
				System.out.println(omElement.getText());
			}

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

public static Options buildOptions(){
		Options options = new Options();
		
		options.setTo(new EndpointReference(url));
		
		options.setAction("GetJITOrderList");
		
		HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
		auth.setUsername(USER_NAME);
		auth.setPassword(USER_PWD);

		options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
		
		options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
		
		return options;
	}

public static OMElement buildParam(){
		OMFactory factory = OMAbstractFactory.getOMFactory();
		
		OMNamespace namespace = factory.createOMNamespace(QNAME_URL, "tns");
		
		OMElement date = factory.createOMElement("MT_JITInfo_Request",namespace);
		
		OMElement input = factory.createOMElement("DATUM",namespace);
		input.addChild(factory.createOMText(input, "20130609"));
		
		OMElement input2 = factory.createOMElement("ORDER",namespace);
		input2.addChild(factory.createOMText(input2, "X"));
		
		OMElement input3 = factory.createOMElement("MATNR",namespace);
		input3.addChild(factory.createOMText(input3, "X"));
		
		OMElement input4 = factory.createOMElement("ZTBBJ",namespace);
		input4.addChild(factory.createOMText(input4, "X"));
		
		date.addChild(input);
		date.addChild(input2);
		date.addChild(input3);
		date.addChild(input4);
		
		return date;
	}

67,549

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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