[英]CXF wsdl2java: No adress location in wsdl:port tag
使用CXF(Spring中的配置)創建Web服務時,生成的WSDL缺少端口標記中的地址位置。 這對客戶端來說是個問題。 如果使用CXF進行客戶端創建,則必須在客戶端代碼中以編程方式設置端點。 如果使用Axis(我的Web服務的使用者希望能夠使用Axis 1),則會出錯
Error in generating Java from WSDL: java.io.IOException:
Emitter failure. Cannot find endpoint address in port FooServiceSOAPPort
in service FooServiceLocator
我沒有被迫使用CXF或Axis2創建客戶端並在客戶端代碼中手動設置端點,而是希望擁有以下子元素:
<soap:address location="http://localhost:9000/services/foo"/>
在我的WSDL中的標簽<wsdl:port binding="..." name="...>
(由我的服務代碼由CXF生成)。
如果我將WSDL保存為本地文件並手動添加上面的行,則使用Axis生成客戶端時沒有任何問題,客戶端不需要手動端點設置,一切正常。 那么, 如何使地址位置行出現在CXF生成的WSDL中?
這是我的Spring配置(相關端點標記):
<jaxws:endpoint xmlns:hel="http://user.services/"
name="Foo"
address="/services/foo"
implementor="services.foo.FooImpl"/>
這是我的服務界面:
@WebService
public interface Foo {
String method1(String arg1);
}
和實施
@WebService(endpointInterface = "services.foo.Foo")
@SOAPBinding(style = Style.DOCUMENT, use = Use.LITERAL)
public class FooImpl implements Foo {
@WebMethod(operationName = "method1")
public String method1(String arg1) {
return "OK";
}
}
我的第一個問題是如何生成WSDL文件。 使用Ant或Maven。 如果您使用Maven,將解決您的問題。
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-java2ws-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>process-classes</id>
<phase>process-classes</phase>
<configuration>
<className>com.stackoverflow.cxf.HelloWorld</className>
<genWsdl>true</genWsdl>
<verbose>true</verbose>
<address>http://localhost:9999/blah/blah</address>
</configuration>
<goals>
<goal>java2ws</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
在<address>
您可以指定所需的那個。 如果您使用的是java2ws命令行工具(由cxf提供),則可以使用-address命令行參數指定相同的命令。 CXF java2ws工具 。 我嘗試使用CXF 2.5.9版本。 生成示例Web服務,以下是生成的wsdl的片段。
<wsdl:service name="HelloWorldService">
<wsdl:port name="HelloWorldPort" binding="tns:HelloWorldServiceSoapBinding">
<soap:address location="http://localhost9999/blah/blah"/>
</wsdl:port>
</wsdl:service>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.