I'm coming from C# so I realize that I can't expect a lot of the (great) usability features and functionality to be there in Java, but I've been sort of put on this Java project recently and I simply cannot figure this out. In C# / .NET making web service proxy classes and generated data contracts was pie but for some reason the Java implementation of web services just doesn't seem right to me.
Here's the deal...
I use wsimport to create the generated .java files from .wsdl files. For example...
"%JAVA_HOME%\bin\wsimport" -quiet -extension -s .\src -d .\bin ".\wsdl\MyWSDL.wsdl"
I noticed that this hard-coded (typing that phrase almost made me vomit just now) "wsdlLocation" as the current location of the wsdl ("C:\Users\ME\etc\wsdl\MyWSDL.wsdl"). So I take it out:
"%JAVA_HOME%\bin\wsimport" -quiet -extension -s .\src -d .\bin -wsdllocation "NULL" ".\wsdl\MyWSDL.wsdl"
Now when I instantiate a generated service...
MyService xyz = new MyService();
I get an error. Something along the lines of "can't find file C:\blahblah\Temp\NULL" . OK... back to the drawing board. After having investigated this a little, I found a post here on Stack Overflow that talked about using "classpath:META-INF/WSDL.wsdl" as the wsdl location.
"%JAVA_HOME%\bin\wsimport" ... -wsdllocation "classpath:WSDLs/MyWSDL.wsdl" ".\wsdl\MyWSDL.wsdl"
copy ".\wsdl\*" .\bin\WSDLs
cd bin
"%JAVA_HOME%\bin\jar" cf WebServiceProxies.jar *
Error!
"Unknown protocol: classpath"
Strangely enough, the post on Stack Overflow was marked as the answer. I guess it's possible that over the last two years a decent amount has changed to the point where "classpath:" is no longer supported or there is another method of doing this but I haven't been able to figure it out / find the answer.
OK, so I have one of several questions I need answered (thanks in advance!!!! I'm going nuts over here!).
Is there a way for it to NOT NEED the WSDL at runtime? For what it's worth, I think it's B.S. that it needs this when I instantiate objects. Any way to suppress this requirement? Maybe if I used a different tool...?
If there is NO WAY for this code to not need the WSDL at runtime, how do I get it to pick up this WSDL from the package? What do I put in the wsdllocation argument to make it load the WSDL from within the JAR file?
META-INF\wsdl
and puts this in the final jar that contains the project. (netbeans.org/kb/docs/websvc/jax-ws.html) – Electorate