Hello,
I don't know if anyone could help me, but I tried to contact the Storage Service to retrieve the Owner Profile. However, it's doesn't work : I've got a http error code 500.
private void profileRequest(String url){ if (url == null) url = "https://storage.msn.com/storageservice/SchematizedStore.asmx"; SoapRequest request = new SoapRequest(createRequestGetProfile(),url, "http://www.msn.com/webservices/storage/2008/GetProfile","POST"){ @Override public boolean sendCompleted(String responseStr, int code){ System.out.println(code); System.out.println(responseStr); return false; } }; sendRequestNow(request); } protected static boolean sendRequestNow(SoapRequest soapRequest){ try{ URL url = soapRequest.getAddress(); if (params == null) initParams(); HttpRequestExecutor httpexecutor = new HttpRequestExecutor(); HttpContext context = new BasicHttpContext(null); HttpHost host = new HttpHost(url.getHost(),443,"https"); context.setAttribute(ExecutionContext.HTTP_CONNECTION,conn); context.setAttribute(ExecutionContext.HTTP_TARGET_HOST,host); if (!conn.isOpen()){ SSLContext sc = SSLContext.getInstance("SSLv3"); TrustManager[] tma = { new DummyTrustManager() }; sc.init(null,tma,null); SSLSocketFactory factory = sc.getSocketFactory(); Socket socket = factory.createSocket(host.getHostName(),host.getPort()); conn.bind(socket,params); } BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(soapRequest.getMethod(),url.getPath()); request.setEntity(new XmlEntity(soapRequest.getBody())); context.setAttribute(ExecutionContext.HTTP_REQUEST,request); request.setParams(params); if (soapRequest.getUrlSoap() != null) request.addHeader("SOAPAction",soapRequest.getUrlSoap()); request.addHeader("Host",url.getHost()); httpexecutor.preProcess(request,httpproc,context); HttpResponse response = httpexecutor.execute(request,conn,context); httpexecutor.postProcess(response,httpproc,context); String responseStr = EntityUtils.toString(response.getEntity()); int code = response.getStatusLine().getStatusCode(); try{ conn.close(); }catch (Exception e){ log.log(Level.SEVERE,"",e); return false; } return soapRequest.sendCompleted(responseStr,code); }catch (Exception e){ log.log(Level.SEVERE,"",e); return false; } }
And SoapRequest.class :
package msnp.protocol.services; import java.net.MalformedURLException; import java.net.URL; public abstract class SoapRequest{ private String body, urlSoap, method; private URL address; public SoapRequest(String body, String address, String urlSoap, String method){ this.body = body; try{ this.address = new URL(address); }catch (MalformedURLException e){ e.printStackTrace(); } this.urlSoap = urlSoap; this.method = method; } protected String getBody(){ return body; } protected URL getAddress(){ return address; } protected String getUrlSoap(){ return urlSoap; } protected String getMethod(){ return method; } protected void setAddress(String address){ try{ this.address = new URL(address); }catch (MalformedURLException e){ e.printStackTrace(); } } public abstract boolean sendCompleted(String responseStr, int code); }
Thanks !
Log in to post a comment.
Hello,
I don't know if anyone could help me, but I tried to contact the Storage Service to retrieve the Owner Profile. However, it's doesn't work : I've got a http error code 500.
And SoapRequest.class :
Thanks !