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

本文介绍了SOAP 1.1和1.2版本的绑定方式,并通过一个具体的JSP/Java Servlet实例展示了如何使用HTTP POST请求与GIS HTTP服务器进行交互。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

摘自: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>");

}

}
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:hl7-org:v3" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="PlatformService" targetNamespace="urn:hl7-org:v3"> <wsdl:types> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" targetNamespace="urn:hl7-org:v3" version="1.0"> <xs:element name="HIPMessageServer" type="tns:HIPMessageServer"/> <xs:element name="HIPMessageServerResponse" type="tns:HIPMessageServerResponse"/> <xs:element name="patientRegister" type="tns:patientRegister"/> <xs:element name="patientRegisterResponse" type="tns:patientRegisterResponse"/> <xs:complexType name="patientRegister"> <xs:sequence> <xs:element form="qualified" minOccurs="0" name="in0" type="xs:string"/> <xs:element form="qualified" minOccurs="0" name="in1" type="xs:string"/> <xs:element form="qualified" minOccurs="0" name="in2" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="patientRegisterResponse"> <xs:sequence> <xs:element form="qualified" minOccurs="0" name="patientRegister" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="HIPMessageServer"> <xs:sequence> <xs:element form="qualified" minOccurs="0" name="in0" type="xs:string"/> <xs:element form="qualified" minOccurs="0" name="in1" type="xs:string"/> <xs:element form="qualified" minOccurs="0" name="in2" type="xs:string"/> <xs:element form="qualified" minOccurs="0" name="in3" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="HIPMessageServerResponse"> <xs:sequence> <xs:element form="qualified" minOccurs="0" name="HIPMessageServer" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema> </wsdl:types> <wsdl:message name="patientRegister"> <wsdl:part element="tns:patientRegister" name="parameters"/> </wsdl:message> <wsdl:message name="patientRegisterResponse"> <wsdl:part element="tns:patientRegisterResponse" name="parameters"/> </wsdl:message> <wsdl:message name="HIPMessageServer"> <wsdl:part element="tns:HIPMessageServer" name="parameters"/> </wsdl:message> <wsdl:message name="HIPMessageServerResponse"> <wsdl:part element="tns:HIPMessageServerResponse" name="parameters"/> </wsdl:message> <wsdl:portType name="PlatformService"> <wsdl:operation name="patientRegister"> <wsdl:input message="tns:patientRegister" name="patientRegister"/> <wsdl:output message="tns:patientRegisterResponse" name="patientRegisterResponse"/> </wsdl:operation> <wsdl:operation name="HIPMessageServer"> <wsdl:input message="tns:HIPMessageServer" name="HIPMessageServer"/> <wsdl:output message="tns:HIPMessageServerResponse" name="HIPMessageServerResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="PlatformServiceSoapBinding" type="tns:PlatformService"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="patientRegister"> <soap:operation soapAction="" style="document"/> <wsdl:input name="patientRegister"> <soap:body use="literal"/> </wsdl:input> <wsdl:output name="patientRegisterResponse"> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="HIPMessageServer"> <soap:operation soapAction="" style="document"/> <wsdl:input name="HIPMessageServer"> <soap:body use="literal"/> </wsdl:input> <wsdl:output name="HIPMessageServerResponse"> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="PlatformService"> <wsdl:port binding="tns:PlatformServiceSoapBinding" name="PlatformServicePort"> <soap:address location="http://10.173.79.45/services/PlatformService"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
最新发布
08-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值