现在只知道webservice 的url ,在浏览器上输入url,需要用户名,密码才能打开xml
用java做客户端,怎么才能实现身份认证呢?望大侠们指教下
另外服务端是.net做的,我用xfire,axis都试了,没解决
现在只知道webservice 的url ,在浏览器上输入url,需要用户名,密码才能打开xml
用java做客户端,怎么才能实现身份认证呢?望大侠们指教下
另外服务端是.net做的,我用xfire,axis都试了,没解决
你可以直接用HttpURLConnection来做客户端。
[code="java"]URL url = new URL("http://localhost/Incuity/ContentService.asmx");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("content-type", "text/xml");\根据具体情况定
conn.setDoOutput(true);
String passId = new String(Base64.encode("username:password".getBytes()));
conn.setRequestProperty("Authorization", "Basic "+passId);
conn.connect();
OutputStream os = conn.getOutputStream();
[/code]
通过这个outputStream来发请求
像这样
[code="java"]
String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ " soapenv:Body bin:sayHellomorgan23/bin:sayHello /soapenv:Body/soapenv:Envelope";
os.write(s.getBytes());
[/code]