简体   繁体   English

如何更改 WSDL soap 地址位置,尤其是 url 的上下文部分?

[英]How to change WSDL soap address location , in particular the context part of the url?

Here i'm using java first approach to create web service.在这里,我使用 java first 方法来创建 Web 服务。

I have exposed a web service using JAX-WS by using Endpoint api Endpoint.publish(address,SampleWebService) in JBOSS EAP 6.0 .我通过在 JBOSS EAP 6.0 中使用 Endpoint api Endpoint.publish(address,SampleWebService)公开了一个使用 JAX-WS 的 Web 服务。

Whatever the value i provide for address field in the above publish method, it didn't matter ie, i did not see the impact of that.无论我在上述发布方法中为地址字段提供什么值,都无关紧要,即,我没有看到它的影响。 SampleWebService above is my Web service implementation class.上面的SampleWebService是我的 Web 服务实现类。 After deploying the war file ,i will get WSDL file generated in the following location .部署war文件后,我将在以下位置生成WSDL文件。

%JBOSS_HOME%/standalone/data/wsdl/MyProjectName-1.0-SNAPSHOT.war %JBOSS_HOME%/standalone/data/wsdl/MyProjectName-1.0-SNAPSHOT.war

The above generated WSDL file contains soap:address location = " http://localhost:8080/MyProjectName-1.0-SNAPSHOT/SampleWebService?wsdl "/>上面生成的WSDL文件包含soap:address location = " http://localhost:8080/MyProjectName-1.0-SNAPSHOT/SampleWebService?wsdl "/>

@webService(serviceName="SampleWebService")
public class SampleWebService {
    //Implementation specific logic
}

IS there any way that i can change the context ie, in the soap address location to have MyProjectName instead of MyProjectName-1.0-SNAPSHOT so that the final soap address location will look like following有什么方法可以改变上下文,即在soap地址位置使用MyProjectName而不是MyProjectName-1.0-SNAPSHOT,这样最终的soap地址位置将如下所示

soap:address location = " http://localhost:8080/MyProjectName-1.0-SNAPSHOT/SampleWebService?wsdl "/> soap:address location = " http://localhost:8080/MyProjectName-1.0-SNAPSHOT/SampleWebService?wsdl "/>

Answering my own question.回答我自己的问题。

All i wanted is to change the root context name so that i can provide my own name instead of default war file name (complete name of the war file excluding .war extension)我想要的只是更改根上下文名称,以便我可以提供自己的名称而不是默认的战争文件名(战争文件的完整名称,不包括 .war 扩展名)

In order to change root context of the war file, i need to specify context name in jboss-web.xml file which reside in my web app's WEB-INF folder.为了更改 war 文件的根上下文,我需要在 jboss-web.xml 文件中指定上下文名称,该文件位于我的 Web 应用程序的 WEB-INF 文件夹中。

Thanks to this changing context root name post which helped me in figuring out the solution for my case.感谢这个不断变化的上下文根名称帖子,它帮助我找出了我的案例的解决方案。

Now jboss-webapp.xml contains following content :现在 jboss-webapp.xml 包含以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="  
      http://www.jboss.com/xml/ns/javaee  
      http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
    <context-root>MyProjectName</context-root>
</jboss-web>

The above change has helped me in getting the required soap address location url.上述更改帮助我获得了所需的soap 地址位置url。 ie, <soap:address location="http://localhost:8080/MyProjectName/SampleWebService?wsdl" />即, <soap:address location="http://localhost:8080/MyProjectName/SampleWebService?wsdl" />

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

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