[英]After creating web service client with wsdl2java and using it I get Unexpected Attachment type =class
[英]Web service client using wsdl2java and Spring
我希望基於Spring MVC的應用程序可以使用Web服務。 我對服務唯一了解的是WSDL。
我將W3C中的此示例用於測試目的。
我可以通過CXF的WSDL2Java實用程序生成客戶端的Java工件。 它為我提供了一些接口及其實現以及main方法中的一些用法示例(但為此目的並沒有太大幫助)。
我必須在應用程序中進行什么配置才能簡單地集成此客戶端? 我更喜歡XML conf方法。
使用的版本是:
CXF具有用於配置客戶端的<jaxws:client />
元素。
您可以將@WebService
批注的接口指定為serviceClass
屬性,並將端點URL指定為address
屬性。 例如,假設wsdl2java生成了com.w3schools.webservices.TempConvertSoap
<?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="tempconvertClient"
serviceClass="com.w3schools.webservices.TempConvertSoap"
address="http://www.w3schools.com/webservices/tempconvert.asmx" />
</beans>
您可以將tempconvertClient
bean作為com.w3schools.webservices.TempConvertSoap
注入,並使用它進行服務調用。
有關更多信息,請參見CXF JAX-WS配置文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.