Reputation: 511
I have several WSDL files that I"m using to generate client code to talk to a remote service using SOAP. The generated code includes a line that looks like this:
public class AddProductService extends Service {
static {
URL url = null;
try {
url = new URL("file:/Users/developer/spg/spg-subman/SubscriptionManager/src/main/resources/wsdl/AddProduct.xml");
I've cut out some code that was generated and included only the line that I think is broken.
The WSDL files are in the project in src/main/resources/wsdl
and that directory is not going to exist where this code will be deployed.
I'm using the cxf-codegen-plugin plugin with maven to generate this code.
I have a couple of questions:
classpath:
URL? Upvotes: 0
Views: 275
Reputation: 511
I'm answering this question because I found the answer and I've seen numerous people post code fragments that show the same problem I had, and in fact the cxf code examples demonstrates the same problem. Also I had multiple wsdlf files and how to solve that wasn't clear either.
The element that fixes this issue is:
<wsdlLocation>AddProduct.xml</wsdlLocation>
The problem from my point of view is that tag wsdlLocation suggests a path, but this is not the entry for a path, you just put the wsdl file name here and at run time as long as you include the wsdl, in the class path of the jar file it will be found.
In the end the stanza in the pom for the configuration section of the cxf-codegen-plugin file looked like this:
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/AddProduct.xml</wsdl>
<extraargs>
<extraarg>-client</extraarg>
</extraargs>
<wsdlLocation>AddProduct.xml</wsdlLocation>
</wsdlOption>
</wsdlOptions>
</configuration
The result of this is that in the static declaration you end up with this:
URL url = AddProductService.class.getResource("AddProduct.xml");
and not this:
url = new URL("file:/Users/tonyg/App/MyManager/src/main/resources/wsdl/AddProduct.xml");
Upvotes: 0