简体   繁体   English

如何在CXF Web服务中将根上下文用作wsdl端点

[英]How to use root context as wsdl end point in CXF Web service

I had created web service with java classes generated from WSDL using CXF framework hosted using spring - web app on tomcat. 我已经使用CXF框架使用WSDL生成的Java类创建了Web服务,该CXF框架使用spring-Tomcat上的Web应用程序托管。 my port binding is as shown below. 我的端口绑定如下所示。

<wsdl:service name="ServiceManagement">
        <wsdl:port binding="tns:ServiceManagementSOAP" name="ServiceManagementSOAP">
            <soap:address
                location="http://localhost:8080/XXXXX/services/ServiceManagementSOAP" />
        </wsdl:port>
    </wsdl:service>
  1. I give the url http://localhost:8080/XXXXX/services . 我给网址http://localhost:8080/XXXXX/services
  2. All the wsdl hosted on that server are shown on CXF service list 该服务器上托管的所有wsdl均显示在CXF服务列表中
  3. When I click on individual operations. 当我单击单个操作时。 it opens up to give me wsdl, services/ServiceManagementSOAP?wsdl 它开放给我wsdl,services / ServiceManagementSOAP?wsdl

As for as now everything went fine since I was using hosting it in my local machine. 到目前为止,由于我在本地计算机上托管了主机,所以一切都很好。 Now the problem is. 现在的问题是。 when web service is hosted on different machine and click on individual wsdl in the CXF Service List,it gives me connection not found. 当Web服务托管在另一台计算机上并单击CXF服务列表中的单个wsdl时,它使我找不到连接。 When I verified I can find that Endpoint address is still http://localhost:8080/XXXXX/services/ServiceManagementSOAP . 验证后,我可以发现端点地址仍然是http://localhost:8080/XXXXX/services/ServiceManagementSOAP suppose instead of clicking on WSDL url. 假设不要单击WSDL URL。 Give the WSDL url and replace localhost with IP address of the hosted machine it works fine. 提供WSDL URL,并将localhost替换为工作正常的托管计算机的IP地址。

So now the question is. 所以现在的问题是。 doesn't CXF handle port binding itself by replacing the localhost with root context of web app. CXF无法通过将localhost替换为Web应用程序的根上下文来处理端口绑定本身。 if it doesn't, is there ay solution to work it out. 如果没有,有解决方案可以解决。 SO that when I port the web service to different machine it will automatically update the ip address. 这样,当我将Web服务移植到另一台机器上时,它将自动更新IP地址。

I had the workaround, Since I use tomcat6 plugin to deploy the war file. 我有解决方法,因为我使用tomcat6插件来部署war文件。 When I give the ipaddress of target server(if its localhost, then 127.0.0.1) in url. 当我在网址中提供目标服务器的ipaddress(如果是本地主机,则为127.0.0.1)。 Then IPAddress of the server is displayed in endpoint. 然后,服务器的IP地址显示在端点中。

Endpoint address: http://127.0.0.1:8080/xxxxx/services/YYYYY
WSDL : {http://kp.com/aaaa/webservices/YYYY/}bbbb
Target namespace: http://kp.com/aaaa/webservices/YYYY/

Hence when you click on WSDL in points to corresponding server. 因此,当您单击WSDL时,指向相应的服务器。

However I could not find, how to do it when we deploy it from tomcat manager url 但是我找不到,当我们从tomcat管理器URL部署它时,该怎么做

You can bind your service to http://0.0.0.0:8080/XXXXX/services/ServiceManagementSOAP . 您可以将服务绑定到http://0.0.0.0:8080/XXXXX/services/ServiceManagementSOAP It is the best way which you do not need to assign a specific IP and save your time. 这是不需要分配特定IP并节省时间的最佳方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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