I am having a maven build and project with a webservice client that will be deployed on a wildfly server. In my Client EJB, I have the following
@Stateless
public class MyClientEJB {
@WebServiceRef(wsdlLocation = "http://localhost:8080/HelloWorld/HelloWorldService?wsdl")
private HelloWorldService service;
I want to have different url for Test and Production, how can I have this url as a configurable entry. I tried creating profiles in my pom.xml file but that requires following code and I don't know how to use it in @WebServiceRef annotation.
private void initProperties() {
InputStream is = getClass().getClassLoader().getResourceAsStream("application.properties");
if (is != null) {
try {
properties.load(is);
BASE_URL = (String)properties.getProperty("student.restws.url");
} catch (IOException e) {
logger.error("Error when reading properties: ", e);
throw new RuntimeException("Can not load application.properties file.");
}
} else {
logger.error("Error when finding application.properties.");
throw new RuntimeException("Error when finding application.properties.");
}
}
Any example would be appreciated. Thanks
Update:
I added wsdl folder under src/main/resources/META_INF and copied the wsdl file there. In the @WebServiceRef annotation then updated to @WebServiceRef(wsdlLocation = "META-INF/wsdl/HelloWorld.wsdl")
But I get the following runtime error when webservice is invoked.
Caused by: java.io.IOException: JBAS015526: Child 'META-INF/wsdl/HelloWorld.wsdl' not found for VirtualFile: "/C:/wildfly-8.1.0.Final/bin/content/hello-world.war"
wsdl file has the following defined:
<wsdl:service name="HelloWorldService">
<wsdl:port name="HelloWorldPort" binding="tns:HelloWorldEndpointBinding" >
<soap:address location="http://localhost:9090/HelloWorldPort"/>
</wsdl:port>
</wsdl:service>