对方给出的接口文档的方法 http://www.anjismart.com:7770/QueryCodeService.asmx?op=QueryCode
想要做一个在自己网站上能查到的防伪验证 求教在jsp页面上要写什么java页面上些什么,应该要写哪些东西,或者有个类似的学习例子也好
-------------------------------------------------------------------------------------------------------------
HTTP GET
以下是 HTTP GET 请求和响应示例。所显示的占位符需替换为实际值。GET /QueryCodeService.asmx/QueryCode?code=string&aid=string HTTP/1.1
Host: www.anjismart.comHTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://www.anjismart.com/">string</string>
-----------------------------------------------------------------------------------------------------------------------------------
1.1接口地址http://www.anjismart.com:7770/QueryCodeService.asmx/QueryCode?code=***************&aid=302
1.2http请求方式
Get
1.3参数列表
参数 是否必须 说明
code 是 需要被查询的防伪码。
aid 是 查询通道号使用302号通道。请严格填写,否则可能会遭到系统自动屏蔽!
1.4返回说明
正常情况下,系统会返回如下
[RESULT];[FIRSTQUETYDATE]参数 说明
RESULT 查询结果:
0:首次查询
1-9:多次查询(当查询次数大于等于10时,返回结构为9.)
?:防伪码位数错误或格式错误。
-:未找到的防伪码。
j:被系统注销的防伪码。
FIRSTQUETYDATE 改号码首次被查询时间,若本次查询即为首次查询,则返回12位0。若发生错误返回格式如下
error;[ERRORREASON] 参数 说明
ERRORREASON 错误原因(可能不存在):
Error code length!
提交的防伪码长度错误。
There is error word(s) in the code!
提交的防伪码中存在非法内容。1.5请求实例
http://www.anjismart.com:7770/QueryCodeService.asmx/QueryCode?code=425144174493800&aid=302
1.6返回实例
首次查询
0:000000000000
非首次查询
1:201501131516
想要做一个在自己网站上能查到的防伪验证 求教在jsp页面上要写什么java页面上些什么,应该要写哪些东西,或者有个类似的学习例子也好
-------------------------------------------------------------------------------------------------------------
HTTP GET
以下是 HTTP GET 请求和响应示例。所显示的占位符需替换为实际值。GET /QueryCodeService.asmx/QueryCode?code=string&aid=string HTTP/1.1
Host: www.anjismart.comHTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://www.anjismart.com/">string</string>
-----------------------------------------------------------------------------------------------------------------------------------
1.1接口地址http://www.anjismart.com:7770/QueryCodeService.asmx/QueryCode?code=***************&aid=302
1.2http请求方式
Get
1.3参数列表
参数 是否必须 说明
code 是 需要被查询的防伪码。
aid 是 查询通道号使用302号通道。请严格填写,否则可能会遭到系统自动屏蔽!
1.4返回说明
正常情况下,系统会返回如下
[RESULT];[FIRSTQUETYDATE]参数 说明
RESULT 查询结果:
0:首次查询
1-9:多次查询(当查询次数大于等于10时,返回结构为9.)
?:防伪码位数错误或格式错误。
-:未找到的防伪码。
j:被系统注销的防伪码。
FIRSTQUETYDATE 改号码首次被查询时间,若本次查询即为首次查询,则返回12位0。若发生错误返回格式如下
error;[ERRORREASON] 参数 说明
ERRORREASON 错误原因(可能不存在):
Error code length!
提交的防伪码长度错误。
There is error word(s) in the code!
提交的防伪码中存在非法内容。1.5请求实例
http://www.anjismart.com:7770/QueryCodeService.asmx/QueryCode?code=425144174493800&aid=302
1.6返回实例
首次查询
0:000000000000
非首次查询
1:201501131516
解决方案 »
- 向NC发送XML的方法,回执总报,从输入流转换document出错:请检验文档格式。
- 点击提交按扭时不要弹出一个网页的问题???
- 谁有java开发员scwcd认证的试题
- jsp text问题
- sun one directory安装错误
- java有什么好处?
- 求String的长度???在线等待,谢谢!
- 急救!!jsp出错,总是提示java.lang.NoClassDefFoundError:
- 在JSP中判断一个字符串的首字符是否为字母?
- 服务端如何读取客户端的文件?
- 用webSocket发送消息怎么确定用户收到消息了呢
- 求救,大神们,easyui的combogrid怎么隐藏周围的边框和下拉框,变成文本的样子
URL url = new URL(strURL);
HttpURLConnection httpConn = (HttpURLConnection)
url.openConnection();
httpConn.setRequestMethod("GET");
httpConn.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(
httpConn.getInputStream()));
String line;
StringBuffer buffer = new StringBuffer();
while ((line = reader.readLine()) != null) {
buffer.append(line);
}
reader.close();
httpConn.disconnect();
System.out.println(buffer.toString());
/**
* 程序中访问http数据接口
*/
public static String getURLContent(String urlStr) {
/** 网络的url地址 */
URL url = null;
/** http连接 */
HttpURLConnection httpConn = null;
/**//** 输入流 */
BufferedReader in = null;
StringBuffer sb = new StringBuffer();
try {
url = new URL(urlStr);
in = new BufferedReader(new InputStreamReader(url.openStream(), "GBK"));
String str = null;
while ((str = in.readLine()) != null) {
sb.append(str);
}
} catch (Exception ex) { } finally {
try {
if (in != null) {
in.close();
}
} catch (IOException ex) {
}
}
String result = sb.toString();
System.out.println(result);
return result;
}
...
public static final String reqPath = "https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=ACCESS_TOKEN";
// 连接微信接口,群发消息
public static JSONObject connectWeiXinInterface(String reqPath, String json) {
URL url;
String result = "";
JSONObject jsonObject = null;
try {
url = new URL(reqPath);
HttpURLConnection http = (HttpURLConnection) url.openConnection();
http.setRequestMethod("POST");
http.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
http.setDoInput(true);
http.setDoOutput(true);
System.setProperty("sun.net.client.defaultConnectTimeout", "30000");// 连接超时30秒
System.setProperty("sun.net.client.defaultReadTimeout", "30000"); // 读取超时30秒 http.connect();
OutputStream os = http.getOutputStream();
os.write(json.getBytes("UTF-8"));// 传入参数
InputStream is = http.getInputStream();
int size = is.available();
byte[] b = new byte[size];
is.read(b);
result = new String(b, "UTF-8");
log.info("请求返回结果:" + result);
jsonObject = JSONObject.fromObject(result);
os.flush();
os.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return jsonObject;
}
...
确定这代码在jdk1.7和1.6上的执行是一样的么?