|
1 將 wevservice 用戶端 通過<jaxws:client>元素,注入到spring的設定檔中,類似<jaxws:endpoint>元素被使用者服務端
2 具體的例子
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<jaxws:client id="helloClient"
serviceClass="demo.spring.HelloWorld"
address="http://localhost:9002/HelloWorld" />
</beans>
<jaxws:client>元素說明:
id: String類型,唯一標識,可以被spring的bean進行調用
serviceClass:Class 類型,內容為完整的類名稱,SEI 介面名
address:QName 類型,對應wsdl:service@name.
endpointName :QName,對應wsdl:port@name
wsdlLocation:URL類型,A URL to connect to in order to retrieve the WSDL for the service. This is not required
3 更詳細的例子
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <!-- Interceptors extend e.g. org.apache.cxf.phase.AbstractPhaseInterceptor --> <bean id="anotherInterceptor" class="..." /> <!-- Handlers implement e.g. javax.xml.ws.handler.soap.SOAPHandler --> <bean id="jaxwsHandler" class="..." /> <!-- The SOAP client bean --> <jaxws:client id="helloClient" serviceClass="demo.spring.HelloWorld" address="http://localhost:9002/HelloWorld"> <jaxws:inInterceptors> <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/> <ref bean="anotherInterceptor"/> </jaxws:inInterceptor> <jaxws:handlers> <ref bean="jaxwsHandler" /> </jaxws:handlers> <jaxws:properties> <entry key="mtom-enabled" value="true"/> </jaxws:properties> </jaxws:client></beans>
<jaxws:client>子項目:
jaxws:inInterceptors:攔截器,必須實現Each should implement org.apache.cxf.interceptor.Interceptor or org.apache.cxf.phase.PhaseInterceptor
jaxws:handlers:處理類,必須實現javax.xml.ws.handler.Handler or javax.xml.ws.handler.soap.SOAPHandler.
jaxws:properties :屬性, MAP |