[英]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.