简体   繁体   中英

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.

I have exposed a web service using JAX-WS by using Endpoint api Endpoint.publish(address,SampleWebService) in JBOSS EAP 6.0 .

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. After deploying the war file ,i will get WSDL file generated in the following location .

%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 "/>

@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: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)

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.

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 :

<?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. ie, <soap:address location="http://localhost:8080/MyProjectName/SampleWebService?wsdl" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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