服务器未能识别 HTTP 头 SOAPAction

J2EE 码拜 9年前 (2015-04-02) 1489次浏览 0个评论

这是http://www.36wu.com提供的接口信息,但是始终报异常:服务器未能识别 HTTP 头 SOAPAction 的值的错误,求大拿指点。

服务器未能识别 HTTP 头 SOAPAction

服务器未能识别 HTTP 头 SOAPAction
String mobile = "18710102020";
			String output = "json";
			String authkey = "";

			RPCServiceClient serviceClient = new RPCServiceClient();
			Options options = serviceClient.getOptions();
			EndpointReference targetEPR = new EndpointReference("http://web.36wu.com/MobileService.asmx?WSDL");
			options.setTo(targetEPR);

			QName opAddEntry = new QName("http://www.36wu.com/", "GetMobileOwnership");

			Object[] opAddEntryArgs = new Object[]{mobile,output,authkey};

			Class[] classes = new Class[]{String.class,String.class,String.class};

			Object[] result =serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, classes);
服务器未能识别 HTTP 头 SOAPAction
这是要沉了的意思吗?
服务器未能识别 HTTP 头 SOAPAction
Object[] ret = null;
    	   RPCServiceClient   serviceClient = new RPCServiceClient();
           Options options = serviceClient.getOptions();
           EndpointReference targetEPR = new EndpointReference("http://web.36wu.com/MobileService.asmx?WSDL");
           options.setTo(targetEPR);
           QName opQName = new QName("http://www.36wu.com/", "GetMobileOwnership");
           ret = serviceClient.invokeBlocking(opQName, new Object[] { "18710102020",""},  new Class[] { String[].class });
           System.out.println(ret);

试试看看。

服务器未能识别 HTTP 头 SOAPAction
引用 3 楼 rui888 的回复:
Object[] ret = null;
    	   RPCServiceClient   serviceClient = new RPCServiceClient();
           Options options = serviceClient.getOptions();
           EndpointReference targetEPR = new EndpointReference("http://web.36wu.com/MobileService.asmx?WSDL");
           options.setTo(targetEPR);
           QName opQName = new QName("http://www.36wu.com/", "GetMobileOwnership");
           ret = serviceClient.invokeBlocking(opQName, new Object[] { "18710102020",""},  new Class[] { String[].class });
           System.out.println(ret);

试试看看。

还是报同样的错误,那个地址怎么试都不好使,不知道为什么。

服务器未能识别 HTTP 头 SOAPAction
你加上options.setAction(“http://www.36wu.com/GetMobileOwnership”);

看看。我这里用代理,我是显示超时的错误。
你可以http 的方式不过解析比较麻烦。 

服务器未能识别 HTTP 头 SOAPAction
40分
 String s =
		 "http://web.36wu.com/MobileService.asmx?op=GetMobileOwnership";
		 URL url = new URL(s);
		 HttpURLConnection http = (HttpURLConnection) url.openConnection();

		 http.setDoOutput(true);
		 http.setDoInput(true);
		 http.setRequestMethod("POST");
		 http.setUseCaches(false);
		 http.setRequestProperty("Content-Type", "text/xml");
		 http.connect();

		 OutputStream out = http.getOutputStream();

		 String content =
		 "<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">"
		 + "<soap:Body>"
		 + "<GetMobileOwnership xmlns="http://www.36wu.com/">"
			 + "<mobile>18710102020</mobile>"
			 + "<authkey></authkey>"
			 + "</GetMobileOwnership>"
		 + "</soap:Body>"
		 + "</soap:Envelope>";
		 out.write(content.getBytes());

		 out.flush();
		 out.close();

		 BufferedReader reader = new BufferedReader(new InputStreamReader(http
		 .getInputStream()));
		 String line;
		 StringBuffer buffer = new StringBuffer();
		 while ((line = reader.readLine()) != null) {
		 buffer.append(line);
		 }
		 reader.close();
		 http.disconnect();
		 System.out.println(buffer.toString());
服务器未能识别 HTTP 头 SOAPAction
解决了告诉下。
服务器未能识别 HTTP 头 SOAPAction
引用 5 楼 rui888 的回复:

你加上options.setAction(“http://www.36wu.com/GetMobileOwnership”);

看看。我这里用代理,我是显示超时的错误。
你可以http 的方式不过解析比较麻烦。 

还是有问题:

服务器未能识别 HTTP 头 SOAPAction
引用 7 楼 rui888 的回复:

解决了告诉下。

log4j:WARN No appenders could be found for logger (org.apache.axis2.context.AbstractContext).
log4j:WARN Please initialize the log4j system properly.
org.apache.axis2.AxisFault: System.Web.Services.Protocols.SoapException: 服务器无法处理请求。 —> System.NullReferenceException: 未将对象引用设置到对象的实例。
   在 Cloud.Api.Webservice.CloudSoapHeader.IsValid(String authkey)
   在 Cloud.Api.Webservice.MobileService.GetMobileOwnership(String mobile, String authkey)
   — 内部异常堆栈跟踪的结尾 —

服务器未能识别 HTTP 头 SOAPAction
http 的方式我测试可以。

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetMobileOwnershipResponse xmlns="http://www.36wu.com/"><GetMobileOwnershipResult><status>401</status><message>错误的authkey或未授权的authkey,请您购买服务!</message></GetMobileOwnershipResult></GetMobileOwnershipResponse></soap:Body></soap:Envelope>
服务器未能识别 HTTP 头 SOAPAction
引用 6 楼 rui888 的回复:
 String s =
		 "http://web.36wu.com/MobileService.asmx?op=GetMobileOwnership";
		 URL url = new URL(s);
		 HttpURLConnection http = (HttpURLConnection) url.openConnection();

		 http.setDoOutput(true);
		 http.setDoInput(true);
		 http.setRequestMethod("POST");
		 http.setUseCaches(false);
		 http.setRequestProperty("Content-Type", "text/xml");
		 http.connect();

		 OutputStream out = http.getOutputStream();

		 String content =
		 "<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">"
		 + "<soap:Body>"
		 + "<GetMobileOwnership xmlns="http://www.36wu.com/">"
			 + "<mobile>18710102020</mobile>"
			 + "<authkey></authkey>"
			 + "</GetMobileOwnership>"
		 + "</soap:Body>"
		 + "</soap:Envelope>";
		 out.write(content.getBytes());

		 out.flush();
		 out.close();

		 BufferedReader reader = new BufferedReader(new InputStreamReader(http
		 .getInputStream()));
		 String line;
		 StringBuffer buffer = new StringBuffer();
		 while ((line = reader.readLine()) != null) {
		 buffer.append(line);
		 }
		 reader.close();
		 http.disconnect();
		 System.out.println(buffer.toString());

包导不进来,应该不是用的axis2吧。

服务器未能识别 HTTP 头 SOAPAction
 

引用 11 楼 u011279706 的回复:
Quote: 引用 6 楼 rui888 的回复:
 String s =
		 "http://web.36wu.com/MobileService.asmx?op=GetMobileOwnership";
		 URL url = new URL(s);
		 HttpURLConnection http = (HttpURLConnection) url.openConnection();

		 http.setDoOutput(true);
		 http.setDoInput(true);
		 http.setRequestMethod("POST");
		 http.setUseCaches(false);
		 http.setRequestProperty("Content-Type", "text/xml");
		 http.connect();

		 OutputStream out = http.getOutputStream();

		 String content =
		 "<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">"
		 + "<soap:Body>"
		 + "<GetMobileOwnership xmlns="http://www.36wu.com/">"
			 + "<mobile>18710102020</mobile>"
			 + "<authkey></authkey>"
			 + "</GetMobileOwnership>"
		 + "</soap:Body>"
		 + "</soap:Envelope>";
		 out.write(content.getBytes());

		 out.flush();
		 out.close();

		 BufferedReader reader = new BufferedReader(new InputStreamReader(http
		 .getInputStream()));
		 String line;
		 StringBuffer buffer = new StringBuffer();
		 while ((line = reader.readLine()) != null) {
		 buffer.append(line);
		 }
		 reader.close();
		 http.disconnect();
		 System.out.println(buffer.toString());

包导不进来,应该不是用的axis2吧。

不是的  import java.net.HttpURLConnection;
import java.net.URL;

服务器未能识别 HTTP 头 SOAPAction
引用 10 楼 rui888 的回复:

http 的方式我测试可以。

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetMobileOwnershipResponse xmlns="http://www.36wu.com/"><GetMobileOwnershipResult><status>401</status><message>错误的authkey或未授权的authkey,请您购买服务!</message></GetMobileOwnershipResult></GetMobileOwnershipResponse></soap:Body></soap:Envelope>

是的,这种方法的确能成功,可是不明白我那种调用方式问题出在什么地方。

服务器未能识别 HTTP 头 SOAPAction
引用 12 楼 rui888 的回复:

 

Quote: 引用 11 楼 u011279706 的回复:
Quote: 引用 6 楼 rui888 的回复:
 String s =
		 "http://web.36wu.com/MobileService.asmx?op=GetMobileOwnership";
		 URL url = new URL(s);
		 HttpURLConnection http = (HttpURLConnection) url.openConnection();

		 http.setDoOutput(true);
		 http.setDoInput(true);
		 http.setRequestMethod("POST");
		 http.setUseCaches(false);
		 http.setRequestProperty("Content-Type", "text/xml");
		 http.connect();

		 OutputStream out = http.getOutputStream();

		 String content =
		 "<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">"
		 + "<soap:Body>"
		 + "<GetMobileOwnership xmlns="http://www.36wu.com/">"
			 + "<mobile>18710102020</mobile>"
			 + "<authkey></authkey>"
			 + "</GetMobileOwnership>"
		 + "</soap:Body>"
		 + "</soap:Envelope>";
		 out.write(content.getBytes());

		 out.flush();
		 out.close();

		 BufferedReader reader = new BufferedReader(new InputStreamReader(http
		 .getInputStream()));
		 String line;
		 StringBuffer buffer = new StringBuffer();
		 while ((line = reader.readLine()) != null) {
		 buffer.append(line);
		 }
		 reader.close();
		 http.disconnect();
		 System.out.println(buffer.toString());

包导不进来,应该不是用的axis2吧。

不是的  import java.net.HttpURLConnection;
import java.net.URL;

嗯,是的。这种方法也能成功。可是我在纠结之前的调用方式问题在哪,   非常感谢咯!

服务器未能识别 HTTP 头 SOAPAction
你看网上 的这个可以不

//      // 使用RPC方式调用WebService
//		    RPCServiceClient ser = new RPCServiceClient();
//		    Options options = ser.getOptions();
//		// 指定调用WebService的URL
//		    EndpointReference targetEPR = new EndpointReference(
//		    "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?WSDL");
//		    options.setTo(targetEPR);
//		    options.setAction("http://WebXml.com.cn/getMobileCodeInfo");
//		// 指定getMobileCodeInfo方法的参数值
//		    Object[] opAddEntryArgs = new Object[] { "15818843224","15848888" };
//		// 指定getMobileCodeInfo方法返回值的数据类型的Class对象
//		    Class[] classes = new Class[] { String.class,String.class };
//		// 指定要调用的getMobileCodeInfo方法及WSDL文件的命名空间
//		    QName opAddEntry = new QName("http://WebXml.com.cn/","getMobileCodeInfo");
//		// 调用getMobileCodeInfo方法并输出该方法的返回值
//		    Object[] str = ser.invokeBlocking(opAddEntry, opAddEntryArgs, classes);
////		System.out.println(ser.invokeBlocking(opAddEntry, opAddEntryArgs));
//
服务器未能识别 HTTP 头 SOAPAction
引用 15 楼 rui888 的回复:

你看网上 的这个可以不

//      // 使用RPC方式调用WebService
//		    RPCServiceClient ser = new RPCServiceClient();
//		    Options options = ser.getOptions();
//		// 指定调用WebService的URL
//		    EndpointReference targetEPR = new EndpointReference(
//		    "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?WSDL");
//		    options.setTo(targetEPR);
//		    options.setAction("http://WebXml.com.cn/getMobileCodeInfo");
//		// 指定getMobileCodeInfo方法的参数值
//		    Object[] opAddEntryArgs = new Object[] { "15818843224","15848888" };
//		// 指定getMobileCodeInfo方法返回值的数据类型的Class对象
//		    Class[] classes = new Class[] { String.class,String.class };
//		// 指定要调用的getMobileCodeInfo方法及WSDL文件的命名空间
//		    QName opAddEntry = new QName("http://WebXml.com.cn/","getMobileCodeInfo");
//		// 调用getMobileCodeInfo方法并输出该方法的返回值
//		    Object[] str = ser.invokeBlocking(opAddEntry, opAddEntryArgs, classes);
////		System.out.println(ser.invokeBlocking(opAddEntry, opAddEntryArgs));
//

还是SoapException: 服务器无法处理请求。    我已被征服了,只能问问对方看下是不是他那边原因。

服务器未能识别 HTTP 头 SOAPAction
10分
package com.mine;

import com._36wu.www.MobileServiceSoapProxy;

public class Mytest  {

	public static void main(String[] args) throws Exception {

		MobileServiceSoapProxy mobileServiceSoapProxy=new MobileServiceSoapProxy("http://web.36wu.com/MobileService.asmx?op=GetMobileOwnership");

		String mobile="139",authkey="authkey";
		com._36wu.www.ResultOfMobileOwnership mos=mobileServiceSoapProxy.getMobileOwnership(mobile, authkey);

		System.out.print(mos.getMessage());


	}

}


错误信息:

三月 18, 2015 6:15:16 下午 org.apache.axis.utils.JavaUtils isAttachmentSupported
警告: Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
错误的authkey或未授权的authkey,请您购买服务!

服务器未能识别 HTTP 头 SOAPAction
说明一下,使用ecplise, 
新建一个java项目,然后new->other->web service cilent,  service definition填入 http://web.36wu.com/MobileService.asmx?WSDL,网络保持畅通,几秒钟之后,点击finish。自动生成了相关类。

然后上面的代码就可以用了

服务器未能识别 HTTP 头 SOAPAction
引用 18 楼 tianfang 的回复:

说明一下,使用ecplise, 
新建一个java项目,然后new->other->web service cilent,  service definition填入 http://web.36wu.com/MobileService.asmx?WSDL,网络保持畅通,几秒钟之后,点击finish。自动生成了相关类。

然后上面的代码就可以用了

嗯,可是只返回了status和message,其余几个返回参数要怎么获取

服务器未能识别 HTTP 头 SOAPAction
引用 18 楼 tianfang 的回复:

说明一下,使用ecplise, 
新建一个java项目,然后new->other->web service cilent,  service definition填入 http://web.36wu.com/MobileService.asmx?WSDL,网络保持畅通,几秒钟之后,点击finish。自动生成了相关类。

然后上面的代码就可以用了

解决了,谢谢!

服务器未能识别 HTTP 头 SOAPAction
http://goobbe.com/questions/2063077/is-it-normal-to-throw-an-exception-over-soap-webservice-server-to-the-client

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明服务器未能识别 HTTP 头 SOAPAction
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!