CXF 提供的Service Transport-HTTP Transport

   完整代码参考http://springsfeng.iteye.com/blog/1634753附件。

    CXF提供两种类型的HTTP Transport

    (1) SOAP over HTTP

    Simple Object Access Protocol(SOAP)是服务消费者和服务提供者之间传输和交换Web Service Message的语言格式。

    Message常常基于Web进行交互,而SOAPMessage基于HTTP协议进行路由。通过这种方式可以使Client和Server运

    行在不同的平台上,同时SOAP也可以使用其他的Transport: SMTP,FTP,JMS.但是最常使用的Transport是HTTP.

    SOAP1.1 over HTTP:

<wsdl:binding name="OrderProcessServiceSoapBinding" type="tns:OrderProcess">
		<soap:binding style="document"
			transport="http://schemas.xmlsoap.org/soap/http" />
...
</wsdl:binding/>
<wsdl:service name="OrderProcessService">
		<wsdl:port binding="tns:OrderProcessServiceSoapBinding"
			name="OrderProcessPort">
			<soap:address location="http://localhost:8080/OrderProcess" />
		</wsdl:port>
</wsdl:service>

     SOAP1.2 over HTTP:

<wsdl:binding name="OrderProcessServiceSoapBinding" type="tns:OrderProcess">
		<soap12:binding style="document"
			transport="http://schemas.xmlsoap.org/soap/http" />
...
</wsdl:binding/>
<wsdl:service name="OrderProcessService">
		<wsdl:port binding="tns:OrderProcessServiceSoapBinding"
			name="OrderProcessPort">
			<soap12:address location="http://localhost:8080/OrderProcess" />
		</wsdl:port>
</wsdl:service>

    (2) HTTP Only

    即通过HTTP 协议格式发送Web Service Message。例如:

<binding name="OrderProcessServiceHttpBinding" type="OrderProcess">
	<http:binding verb="GET" />
	<operation name="processOrder">
		<http:operation location="processOrder" />
		<input>
			<http:urlEncoded />
		</input>
		<output>
			<mime:content type="text/html" />
		</output>
	</operation>
</binding>
<wsdl:service name="OrderProcessService">
	<wsdl:port binding="tns:OrderProcessServiceHttpBinding" name="OrderProcessPort">
		<http:address location="http://localhost:8080/OrderProcess">
	</wsdl:port>
</wsdl:service>

     (3) HTTP Conduit(管道)

     HTTP conduits是一种通道允许开发者使用HTTP相关的Properties或Attributes来影响Endpoint之间的消息交换。

     例如:

<beans … 
	xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" …

	<http-conf:conduit name="{http://order.demo} OrderProcessImplPort.http-conduit">
		<http-conf:client Connection="Keep-Alive" AllowChunking="false" />
		<http-conf:tlsClientParameters
			secureSocketProtocol="SSL">
		</http-conf:tlsClientParameters>
	</http-conf:conduit>
	…
</beans>

     (4) HTTP destination

     Server端的Endpoint使用Destination去指定HTTP Attributes,例如:

<beans ...
	...
	<http-conf:destination name="{http://order.demo}OrderProcessImplPort.http-destination">
		<http-conf:server HonorKeepAlive="true" />
	</http-conf:destination>
</beans>

猜你喜欢

转载自springsfeng.iteye.com/blog/1637743