View Full Version : Getting started w/ java and axis
geoffballinger
28-11-07, 11:45
We are a java house server side - and to add to the problems have never needed to use SOAP before - use XMLRPC for everything internally.
The usual package for doing SOAP in java appears to be apache axis - I am using axis (http://ws.apache.org/axis/) 1.4 w/ xerces 2.9.1 as an XML parser.
I have downloaded the WSDL from the URL in ShopWindow_API.pdf and am now trying to extract a set of java bindings for the API a per the axis docs but I get ...
[geoff@stage axis]$ java -cp \* org.apache.axis.wsdl.WSDL2Java wsdl.xml
java.io.IOException: Type {http://api.productserve.com/}string is referenced but not defined.
at org.apache.axis.wsdl.symbolTable.SymbolTable.check ForUndefined(SymbolTable.java:665)
at org.apache.axis.wsdl.symbolTable.SymbolTable.add(S ymbolTable.java:545)
at org.apache.axis.wsdl.symbolTable.SymbolTable.popul ate(SymbolTable.java:518)
at org.apache.axis.wsdl.symbolTable.SymbolTable.popul ate(SymbolTable.java:495)
at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(P arser.java:361)
at java.lang.Thread.run(Thread.java:619)
Have checked my wsdl.xml and it seems generally sensible though I am no expert. Am sure I must be doing something silly - can anyone suggest what?
Thanks!,
Geoff.
Hi Geoff,
I realise this probably isn't that helpful but I have no idea what any of that means!
Most posts here consist of PHP, HTML, SMARTY and feed questions answered mainly by other ShopWindow users. There's very little developer support here so I think for a speedy and useful answer to your question you might be better off raising a support ticket or emailing one of the SW guys directly.
Of course another poster might prove me wrong...
geoffballinger
28-11-07, 14:37
[geoff@stage axis]$ java -cp \* org.apache.axis.wsdl.WSDL2Java wsdl.xml
java.io.IOException: Type {http://api.productserve.com/}string is referenced but not defined.
Looks like there is potentially a small bug in the WSDL. Looking at ...
<!-- Generic Types -->
<complexType name="ArrayOfInt">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="api:int[]" />
</restriction>
</complexContent>
</complexType>
<complexType name="ArrayOfString">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="api:string[]" />
</restriction>
</complexContent>
</complexType>
... I see that the string and int types are ref'd in the api namespace. If I change the two "api:"s above to be "xsd:" then the stubs are generated without error. Of course I have still to find if they actually work ;) .
I guess since this hasn't bitten the PHP folks here that the PHP SOAP lib must be more forgiving of namespace issues?
Cheers,
Geoff.
geoffballinger
28-11-07, 14:39
Most posts here consist of PHP, HTML, SMARTY and feed questions answered mainly by other ShopWindow users. There's very little developer support here so I think for a speedy and useful answer to your question you might be better off raising a support ticket or emailing one of the SW guys directly.
Yes - I had spotted that when doing a few searches before posting! Will probably do as you suggest since the issue seems (so far!) to be a small bug their side anyway,
G.
I'm getting;
java.io.IOException: Type {http://api.productserve.com/}int is referenced but not defined.
Here is a snipit of code;
// get definition details
WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
InputStream input = new URL(WSDL).openStream();
Document doc = XMLUtils.newDocument(input);
Definition definition = reader.readWSDL(null, doc);
// get service name
QName serviceQN = (QName) definition.getServices().keySet().iterator().next( );
String nameSpaceUri = serviceQN.getNamespaceURI();
String localPart = serviceQN.getLocalPart();
QName serviceQName = new QName(nameSpaceUri, localPart);
// create the service
input = new URL(WSDL).openStream();
Service service = new Service(new URL(WSDL), serviceQName);
When new Service is called it's throwing an exception - spent hours looking into this and it's doing my head in.
Unfortunately I don't know much about SOAP and WSDL but I'm getting there! I'm learning more than I intended - but still getting nowhere.
geoffballinger
29-11-07, 12:37
I'm getting;
java.io.IOException: Type {http://api.productserve.com/}int is referenced but not defined.
Think this is essentially the same problem I had - there is one string and one int that are ref'd in the api namespace. Main difference is that I am downloading the WSDL statically and creating a set of Java stubs to match using the WSDL2Java tool in Axis.
At the moment think that is the required approach since there are both the apparent namespace errors in the WSDL so it requires editing and also the stubs generated are not quite correct and require a small manual tweak (name of the generated exception class isn't consistent throughout) to make them compile.
Should say I am an absolute newbie when it comes to SOAP though so may have the wrong end of several sticks :D!
Geoff.