<soap:binding <soap12:binding <http:binding 三种HTTP绑定

摘自:http://hi.baidu.com/yangtb/blog/item/0fac2fb31ee56da3d8335aa6.html
前面两种SOAP绑定是指采用SOAP规范来形成HTTPRequest,SOAP:binding是采用SOAP1.1版本。soap12:binding是采用SOAP1.2版本。

<soap:binding

<soap12:binding

<http:binding 是采用HTTP规范来填写消息内容,调用方式如下

交互的 Web 接口:

<html>
<head>
<title>HTTP POST vs. WSDL SOAP Web Services
</title>
</head>
<body>

<br>
<center>
<h2><P>Semantic Web Service invoked
via HTTP/POST by JSP/Java Servlet</h2></P>
<FORM action=
"http://157.182.136.51:8080/HttpApp/servlet/SendHTTPRequest" method="post">
<P><b><font color="blue">Simple Server URL:
</font>
http://157.182.136.76/xshi/httpPost/demo1/VBHandler.aspx </b></P>
<P><b><font color="blue">GIS Server URL:
</font>
http://157.182.136.51/agswsprojs/HttpService/getService.aspx </b></P>
<P><b>(--The GIS Server will create a new buffer feature for any
input point features at your specified distance, e.g. 560 meters.--)</b></P>
<P><b>(--Sample source data can be copied from <font color="red">
http://157.182.136.51/agswsprojs/HttpService/WebForm2.aspx</font>--)</b></P>
<div><b>Server Requested: </b>
<input name="ServerURL" type="text" size="80"/></div>
<br>
<div><TEXTAREA NAME="request" COLS=60 ROWS=25></TEXTAREA>
<TEXTAREA NAME="response" COLS=60 ROWS=25></TEXTAREA></div>

<br>
<b>Request</b>
<INPUT TYPE=SUBMIT VALUE="Submit Request">
<b>Response</b>

</FORM>
<b><P><font color="red">Before click the button,
specify the distance in the BufferDistance tags to c
reate the new buffer feature of the input dataset
</font></P></b>

</center>
</body>
</html>



  图 10 显示了 JSP/Java Servlet 客户机用于在服务调用后 与 GIS HTTP 服务器进行交互的 Web 接口:

[img]http://dl.iteye.com/upload/attachment/354740/fc4f96b2-40da-3b60-a225-19bfd571f3f4.jpg[/img]

发送程序:

import java.io.*;
import javax.servlet.*;
import java.util.*;
import java.net.*;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SendRequestServlet extends HttpServlet {

public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{

String strRequest = request.getParameter("request");
String strURL = request.getParameter("ServerURL");

PrintWriter writer = response.getWriter();
response.setContentType("text/html");
writer.println("<html>");
writer.println("<head>");
writer.println("<title>Your requested service is returned</title>");
writer.println("</head>");
writer.println("<body bgcolor=\"white\">");

String newRequest1, newRequest2, newRequest3;
newRequest1 = strRequest.replaceAll("<","<");
newRequest2 = newRequest1.replaceAll(">",">");
newRequest3 = newRequest2.replaceAll("\"",""");

writer.println("<br><br><center><b>Here is your request (left) and
response
(right) </b></center><br><br>" );
writer.println("<center>");
writer.println("<div><TEXTAREA name=\"request\" COLS=60 ROWS=40>"
+ newRequest3 + "</TEXTAREA>");
String outPut;
outPut="";

try
{
URL url;
URLConnection urlConn;
DataOutputStream printout;
DataInputStream input;

url = new URL (strURL);
urlConn = url.openConnection();
urlConn.setDoInput (true);
urlConn.setDoOutput (true);
urlConn.setUseCaches (false);
urlConn.setRequestProperty
("Content-Type", "application/x-www-form-urlencoded");

printout = new DataOutputStream (urlConn.getOutputStream ());

String content = strRequest;
printout.writeBytes (content);
printout.flush ();
printout.close ();

input = new DataInputStream (urlConn.getInputStream ());

String str;
while (null != ((str = input.readLine())))
{
System.out.println (str);
outPut = outPut + str + "\n";
}

input.close ();

}
catch (MalformedURLException me)
{
System.err.println("MalformedURLException: " + me);
}
catch (IOException ioe)
{
System.err.println("IOException: " + ioe.getMessage());
}

String newResponse1, newResponse2, newResponse3;
newResponse1 = outPut.replaceAll("<","<");
newResponse2 = newResponse1.replaceAll(">",">");
newResponse3 = newResponse2.replaceAll("\"",""");

writer.println("<TEXTAREA name=\"request\" COLS=60 ROWS=40>" +
newResponse3
+ "</TEXTAREA> </div>");
writer.println("</center>");
writer.println("</body>");
writer.println("</html>");

}

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值