简体   繁体   English

CXF wsdl2java:wsdl:port标记中没有地址位置

[英]CXF wsdl2java: No adress location in wsdl:port tag

When creating a web-service using CXF (configuration in Spring), my resulting WSDL is missing the address location in port tag. 使用CXF(Spring中的配置)创建Web服务时,生成的WSDL缺少端口标记中的地址位置。 This is problematic for client side. 这对客户端来说是个问题。 If CXF is used for client creation, endpoint must be set programatically in client code. 如果使用CXF进行客户端创建,则必须在客户端代码中以编程方式设置端点。 If Axis is used (the consumer of my web-service wants to be able to use Axis 1), there is an error saying 如果使用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

Instead of being forced to create the client using CXF or Axis2 and manually setting the endpoint in client code, I would like to have the following child element: 我没有被迫使用CXF或Axis2创建客户端并在客户端代码中手动设置端点,而是希望拥有以下子元素:

<soap:address location="http://localhost:9000/services/foo"/>

under the tag <wsdl:port binding="..." name="...> in my WSDL (generated by CXF from my service code). 在我的WSDL中的标签<wsdl:port binding="..." name="...> (由我的服务代码由CXF生成)。

If I save the WSDL as local file and I manually add the line above, client is generated without any problems using Axis, no manual endpoint setting is needed on the client side and everything is OK. 如果我将WSDL保存为本地文件并手动添加上面的行,则使用Axis生成客户端时没有任何问题,客户端不需要手动端点设置,一切正常。 So, how do I make the address location line appear in WSDL generated by CXF? 那么, 如何使地址位置行出现在CXF生成的WSDL中?

Here's my Spring config (relevant endpoint tag): 这是我的Spring配置(相关端点标记):

<jaxws:endpoint xmlns:hel="http://user.services/"
    name="Foo"
    address="/services/foo"
    implementor="services.foo.FooImpl"/>

Here's my service interface: 这是我的服务界面:

@WebService
public interface Foo {
    String method1(String arg1);
}

and implementation 和实施

@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";
    }
}

My first question is how you are generating the WSDL file. 我的第一个问题是如何生成WSDL文件。 Using Ant or Maven. 使用Ant或Maven。 If you are using Maven following will solve your problem. 如果您使用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>

in the <address> you can specify the one you want. <address>您可以指定所需的那个。 If you are using java2ws command line tool (provided by cxf) you can specify the same using -address command line argument. 如果您使用的是java2ws命令行工具(由cxf提供),则可以使用-address命令行参数指定相同的命令。 CXF java2ws tool . CXF java2ws工具 I tried this using CXF version 2.5.9. 我尝试使用CXF 2.5.9版本。 generating sample web service and following is the snippet of resulting wsdl. 生成示例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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM