有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在Soap请求/响应的情况下使用jsoup?

我正在尝试删除this link,但没有成功,因为它需要一个soap请求,并通过soap响应以HTML形式返回结果

这是我的代码,工作不正常

Connection.Response response = Jsoup.connect("http://www.itatonline.in:8080/itat/jsp/runBirt2.jsp?subAction=showReoprt&__report=CaseDetails1_DELHI.rptdesign&searchWhat=searchByAssName&Serial%20No=&Appeal%20No=&Assessee%20Name=&AssType=DontKnow&appealDate=&Bench=AGR").method(Method.GET).timeout(30000).execute();

    String url = "http://www.itatonline.in:8080/itat/jsp/runBirt2.jsp?subAction=showReoprt&__report=CaseDetails1_DELHI.rptdesign&searchWhat=searchByAssName&Serial%20No=&Appeal%20No=&Assessee%20Name=k&AssType=DontKnow&appealDate=&Bench=AGR&__sessionId=20151210_231624_579";
    String rawData = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/>"
            + "<soap:Body><GetUpdatedObjects xmlns=\"http://schemas.eclipse.org/birt\">"
            + "<Operation><Target><Id>Document</Id><Type>Document</Type></Target><Operator>GetPage</Operator><Oprand><Name>Appeal No</Name><Value></Value></Oprand><Oprand><Name>__isdisplay__AppealNo</Name><Value></Value></Oprand><Oprand><Name>Serial No</Name><Value></Value></Oprand><Oprand><Name>__isdisplay__Serial No</Name><Value></Value></Oprand><Oprand><Name>Assessee Name</Name><Value>k</Value></Oprand><Oprand><Name>__isdisplay__Assessee Name</Name><Value>k</Value></Oprand><Oprand><Name>searchWhat</Name><Value>searchByAssName</Value></Oprand><Oprand><Name>__isdisplay__searchWhat</Name><Value>searchByAssName</Value></Oprand><Oprand><Name>AssType</Name><Value>DontKnow</Value></Oprand><Oprand><Name>__isdisplay__AssType</Name><Value>DontKnow</Value></Oprand><Oprand><Name>appealDate</Name><Value></Value></Oprand><Oprand><Name>__isdisplay__appealDate</Name><Value></Value></Oprand><Oprand><Name>Bench</Name><Value>AGR</Value></Oprand><Oprand><Name>__isdisplay__Bench</Name><Value>AGR</Value></Oprand><Oprand><Name>__page</Name><Value>1</Value></Oprand><Oprand><Name>__svg</Name><Value>true</Value></Oprand><Oprand><Name>__page</Name><Value>1</Value></Oprand><Oprand><Name>__taskid</Name><Value>2015-11-9-23-16-22-34</Value></Oprand></Operation></GetUpdatedObjects></soap:Body></soap:Envelope>";       
    URL obj = new URL(url);
    HttpURLConnection con = (HttpURLConnection) obj.openConnection();
    //add reuqest header
    con.setRequestMethod("POST");
    con.setRequestProperty("Content-Type", "text/xml; charset=UTF-8");
    con.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
    con.setRequestProperty("Cookie", response.cookies().toString().replaceAll("[{}]", ""));
    con.setRequestProperty("Host", "www.itatonline.in:8080");
    con.setRequestProperty("Referer", "http://www.itatonline.in:8080/itat/jsp/runBirt2.jsp?subAction=showReoprt&__report=CaseDetails1_DELHI.rptdesign&searchWhat=searchByAssName&Serial%20No=&Appeal%20No=&Assessee%20Name=k&AssType=DontKnow&appealDate=&Bench=AGR");
    con.setRequestProperty("SOAPAction", "");
    con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.3; rv:42.0) Gecko/20100101 Firefox/42.0");
    con.setRequestProperty("X-Prototype-Version", "1.4.0");
    con.setRequestProperty("X-Requested-With", "XMLHttpRequest");
    con.setRequestProperty("request-type", "SOAP");
    // Send post request
    con.setDoOutput(true);

    OutputStreamWriter w = new OutputStreamWriter(con.getOutputStream(), "UTF-8");

    w.write(rawData);
    w.close();

    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));

    String inputLine;
    StringBuffer resp = new StringBuffer();

    while ((inputLine = in.readLine()) != null) {
        resp.append(inputLine);
    }
    in.close();
   System.out.println(resp);

`


共 (0) 个答案