You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Gordon Gekko <di...@tiscalinet.it> on 2005/09/15 14:51:05 UTC

[axis2] client for two web services - wsdl2java

Hi!

I'm using axis2 and my application calls 2 difference web services.

I've used wsdl2java to generate the classes to interact with the 2 web
services.

I'll call the wsdl file that describes the first web service
service1.wsdl and the one that describes the second service2.wsdl.

If I first run wsdl2java on service1.wsdl and then on service2.wsdl I
get the following exception when trying to create a request message for
service1:


Caused by: java.lang.NullPointerException
     at
org.apache.xmlbeans.impl.schema.SchemaTypeImpl.getTypeSystem(SchemaTypeImpl.java:612)
     at
org.apache.xmlbeans.impl.schema.SchemaTypeImpl.getJavaImplClass(SchemaTypeImpl.java:1695)
     at
org.apache.xmlbeans.impl.schema.SchemaTypeImpl.getJavaImplConstructor(SchemaTypeImpl.java:1711)
     at
org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createUnattachedNode(SchemaTypeImpl.java:1839)
     at
org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createTypeStoreUser(SchemaTypeImpl.java:1791)
     at
org.apache.xmlbeans.impl.newstore2.Xobj.setStableType(Xobj.java:1236)
     at org.apache.xmlbeans.impl.newstore2.Cur.setType(Cur.java:2436)
     at org.apache.xmlbeans.impl.newstore2.Cur.setType(Cur.java:2421)
     at
org.apache.xmlbeans.impl.newstore2.Locale.newInstance(Locale.java:575)
     at
org.apache.xmlbeans.impl.newstore2.Locale.newInstance(Locale.java:559)
     at
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.newInstance(SchemaTypeLoaderBase.java:190)
     at
net.ivoa.skyPortal.SubmitDistributedQueryDocument$Factory.newInstance(SubmitDistributedQueryDocument.java:130)
     at
net.ivoa.skyPortal.SkyPortalProxy.submitADQLQuery(SkyPortalProxy.java:66)
     ... 3 more


If I first run wsdl2java on service2.wsdl and then on service1.wsdl,
service1 works fine but I get the following exception when I try to
create a message for service2:


Exception in thread "main" java.lang.NullPointerException
     at
org.apache.xmlbeans.impl.schema.SchemaTypeImpl.getTypeSystem(SchemaTypeImpl.java:612)
     at
org.apache.xmlbeans.impl.schema.SchemaTypeImpl.getJavaImplClass(SchemaTypeImpl.java:1695)
     at
org.apache.xmlbeans.impl.schema.SchemaTypeImpl.getJavaImplConstructor(SchemaTypeImpl.java:1711)
     at
org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createUnattachedNode(SchemaTypeImpl.java:1839)
     at
org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createTypeStoreUser(SchemaTypeImpl.java:1791)
     at
org.apache.xmlbeans.impl.newstore2.Xobj.setStableType(Xobj.java:1236)
     at org.apache.xmlbeans.impl.newstore2.Cur.setType(Cur.java:2436)
     at org.apache.xmlbeans.impl.newstore2.Cur.setType(Cur.java:2421)
     at
org.apache.xmlbeans.impl.newstore2.Locale.newInstance(Locale.java:575)
     at
org.apache.xmlbeans.impl.newstore2.Locale.newInstance(Locale.java:559)
     at
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.newInstance(SchemaTypeLoaderBase.java:190)
     at
org.astrodas.ws.model.InsertMatchingAnnotationsDocument$Factory.newInstance(InsertMatchingAnnotationsDocument.java:110)
     at
org.astrodas.ws.server.AstrodasServerSkeleton.main(AstrodasServerSkeleton.java:172)


I think that the problem might occur because the schema directory is
overwritten by wsdl2java in the second execution.

Am I doing something wrong?

Thanks!

Diego






Re: [axis2] client for two web services - wsdl2java

Posted by Saminda Abeyruwan <sa...@opensource.lk>.
Johan Andersson wrote:

>I am experiencing the exact same problem, using two different client-side
>stubs (generated from two different wsdl:s)
>gives me a nullpointer exception.
>  
>
For the time being, yes, we have problem in keeping multiple schema 
folders in the same classpath. A JIRA is opend for this issue.

>This is somewhat of a showstopper for me =/
>Anyway for me to work around this in the meantime?
>  
>
For the time being (Untill the JIRA is fixed) you have to load single 
stub at a time. :( Please trackdown the JIRA

http://issues.apache.org/jira/browse/AXIS2-225

Saminda 




----- Original Message ----- 
From: "Saminda Abeyruwan" <sa...@opensource.lk>
To: <ax...@ws.apache.org>
Sent: Friday, September 16, 2005 7:21 AM
Subject: Re: [axis2] client for two web services - wsdl2java



>>Hi Gordon,
>>
>>There is a problem if you try to run muliple generted stubs within the
>>same classpath due to "schema" folder. For the moment you have to run
>>two stubs seperately. A JIRA has been opened this regard. Please track
>>it down.
>>
>>Saminda
>>
>>
>>Gordon Gekko wrote:
>>
>>    
>>
>>>Hi Saminda,
>>>
>>>first thanks a lot for your help!
>>>
>>>I don't exactly see what do you mean.  The wsdl2java -o option is in
>>>both cases src, the source directory, where I want the code to be
>>>generated.
>>>
>>>If I generate the code in two separate directories, let's say -o src1
>>>and -o src2, then when I will compile the code in a common bin
>>>directory.  The schema directory will still be overridden in the bin
>>>directory because they have the same name.  On the other hand, I
>>>cannot change the name of one of the two schema directories because
>>>then it will not conform to the package name which is schema.system.foo.
>>>
>>>I also created two jar archives called schema1.jar and schema2.jar
>>>where I put the schema directories generated by the different
>>>executions of wsdl2java and made them available in the classpath.  But
>>>this doesn't solve the problem, the same exceptions still arise.
>>>
>>>Maybe I didn't understand what you were suggesting.  What do you think?
>>>
>>>Thanks a lot again!
>>>
>>>Diego
>>>
>>>
>>>
>>>Saminda Abeyruwan wrote:
>>>
>>>      
>>>
>>>>Gordon Gekko wrote:
>>>>
>>>>        
>>>>
>>>>>I think that the problem might occur because the schema directory is
>>>>>overwritten by wsdl2java in the second execution.
>>>>>          
>>>>>
>>>>
>>>>Yes, if the outpath is same (.. -o ..) the generated schema folder
>>>>will be overridden and cause the null pointer exception. Just give
>>>>another location for service2.wsdl. That would do the trick.
>>>>
>>>>Saminda
>>>>
>>>>
>>>>        
>>>>
>>
>>    
>>
>
>
>
>  
>


Re: [axis2] Parsing a WSDL file

Posted by Eran Chinthaka <ch...@opensource.lk>.
Hi Andrej,

Our OM tree can contain two types of nodes, namely; OMText and OMElement.

The OMElement will contain eii of the xml and OMText will contain 
character ii. Your WSDL (or whatever xml) is having both texts and 
elements under the document element. So casting children.next() to 
either OMText or OMElement will DEFINITELY give you a CCE.

If you just want to print out an XML, use OMOutput.

XMLStreamReader parser = 
XMLInputFactory.newInstance().createXMLStreamReader(
                                                         new 
FileReader("ServisFirstTry1.wsdl"));
StAXOMBuilder builder = new 
StAXOMBuilder(OMAbstractFactory.getOMFactory(), parser);
   OMElement root = builder.getDocumentElement();
OMOutputImpl out = new OMOutputImpl(System.out, false);
root.serialize(out);
out.flush();

But I think you want to do more than just dumping a WSDL :-)

Better read some of the tutorials on the web on AXIOM.



- Chinthaka


Andrej Taranenko wrote:

> Hi,
> I am trying to parse a WSDL file, so I could print out the contents by 
> its elements. The file is attached.
> I am using the following code:
>
>    XMLStreamReader parser = 
> XMLInputFactory.newInstance().createXMLStreamReader(
>                                                          new 
> FileReader("ServisFirstTry1.wsdl"));
>    StAXOMBuilder builder = new 
> StAXOMBuilder(OMAbstractFactory.getOMFactory(), parser);
>    OMElement root = builder.getDocumentElement();
>      System.out.println("WSDL print ");
>    
> System.out.println("--------------------------------------------------");
>    int i = 0;
>    Iterator children = root.getChildren();
>    while (children.hasNext()) {
>        System.out.print(i+": "); i++;
>        OMElement node = (OMElement) children.next();  // <--- 
> exception here!
>        System.out.println(node.getFirstElement().getText());
>    }
>
> but I get the following exception:
> Exception in thread "main" java.lang.ClassCastException: 
> org.apache.axis2.om.impl.llom.OMTextImpl
>    at izpisWSDL.main(izpisWSDL.java:57)
>
> if I use OMText instead of OMElement a different exception occurs.  
> Any help?
>
> Thanks in advance,
> Andrej
>
>------------------------------------------------------------------------
>
><?xml version="1.0" encoding="UTF-8"?>
><definitions name="ServisFirstTry"
> targetNamespace="http://services.axis2.apache.org/ServiceFirstTry"
> xmlns="http://schemas.xmlsoap.org/wsdl/"
> xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:tns="http://services.axis2.apache.org/ServiceFirstTry"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsd1="http://services.axis2.apache.org/xsd"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <types>
> <schema targetNamespace="http://services.axis2.apache.org/xsd"
>             xmlns="http://www.w3.org/2001/XMLSchema"
>             xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>            elementFormDefault="qualified">
>     <element name="metoda4param" type="xsd:string"/>
>     <element name="metoda4return" type="xsd:string"/>
>  </schema> 
> </types>
> <message name="metoda4">
>   <part element="xsd1:metoda4param" name="aVal"/>
> </message>
> <message name="metoda4Response">
>   <part element="xsd1:metoda4return" name="result"/>
> </message>
> <portType name="ServisFirstTryPortType">
>   <operation name="metoda4">
>     <input message="tns:metoda4" name="metoda4"/>
>     <output message="tns:metoda4Response" name="metoda4Response"/>
>   </operation>
> </portType>
> <binding name="ServisFirstTryPortBinding"
>   type="tns:ServisFirstTryPortType">
>   <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
>   <operation name="metoda4">
>     <soap:operation soapAction="metoda4" style="rpc"/>
>     <input name="metoda4">
>       <soap:body namespace="http://services.axis2.apache.org/ServiceFirstTry" use="literal"/>
>     </input>
>     <output name="metoda4Response">
>       <soap:body namespace="http://services.axis2.apache.org/ServiceFirstTry" use="literal"/>
>     </output>
>   </operation>
> </binding>
> <service name="ServisFirstTry">
>   <port binding="tns:ServisFirstTryPortBinding" name="ServisFirstTryPort">
>     <soap:address location="http://localhost/axis2/services/ServisFirstTry.wsdl"/>
>   </port>
> </service>
></definitions>
>

[axis2] Parsing a WSDL file

Posted by Andrej Taranenko <an...@uni-mb.si>.
Hi,
I am trying to parse a WSDL file, so I could print out the contents by 
its elements. The file is attached.
I am using the following code:

    XMLStreamReader parser = 
XMLInputFactory.newInstance().createXMLStreamReader(
                                                          new 
FileReader("ServisFirstTry1.wsdl"));
    StAXOMBuilder builder = new 
StAXOMBuilder(OMAbstractFactory.getOMFactory(), parser);
    OMElement root = builder.getDocumentElement();
   
    System.out.println("WSDL print ");
    
System.out.println("--------------------------------------------------");
    int i = 0;
    Iterator children = root.getChildren();
    while (children.hasNext()) {
        System.out.print(i+": "); i++;
        OMElement node = (OMElement) children.next();  // <--- exception 
here!
        System.out.println(node.getFirstElement().getText());
    }

but I get the following exception:
Exception in thread "main" java.lang.ClassCastException: 
org.apache.axis2.om.impl.llom.OMTextImpl
    at izpisWSDL.main(izpisWSDL.java:57)

if I use OMText instead of OMElement a different exception occurs.  Any 
help?

Thanks in advance,
Andrej

Re: [axis2] client for two web services - wsdl2java

Posted by Johan Andersson <jo...@home.se>.
Hello all,

I am experiencing the exact same problem, using two different client-side
stubs (generated from two different wsdl:s)
gives me a nullpointer exception.

This is somewhat of a showstopper for me =/
Anyway for me to work around this in the meantime?

Regards,
Johan


----- Original Message ----- 
From: "Saminda Abeyruwan" <sa...@opensource.lk>
To: <ax...@ws.apache.org>
Sent: Friday, September 16, 2005 7:21 AM
Subject: Re: [axis2] client for two web services - wsdl2java


> Hi Gordon,
>
> There is a problem if you try to run muliple generted stubs within the
> same classpath due to "schema" folder. For the moment you have to run
> two stubs seperately. A JIRA has been opened this regard. Please track
> it down.
>
> Saminda
>
>
> Gordon Gekko wrote:
>
> > Hi Saminda,
> >
> > first thanks a lot for your help!
> >
> > I don't exactly see what do you mean.  The wsdl2java -o option is in
> > both cases src, the source directory, where I want the code to be
> > generated.
> >
> > If I generate the code in two separate directories, let's say -o src1
> > and -o src2, then when I will compile the code in a common bin
> > directory.  The schema directory will still be overridden in the bin
> > directory because they have the same name.  On the other hand, I
> > cannot change the name of one of the two schema directories because
> > then it will not conform to the package name which is schema.system.foo.
> >
> > I also created two jar archives called schema1.jar and schema2.jar
> > where I put the schema directories generated by the different
> > executions of wsdl2java and made them available in the classpath.  But
> > this doesn't solve the problem, the same exceptions still arise.
> >
> > Maybe I didn't understand what you were suggesting.  What do you think?
> >
> > Thanks a lot again!
> >
> > Diego
> >
> >
> >
> > Saminda Abeyruwan wrote:
> >
> >> Gordon Gekko wrote:
> >>
> >>>
> >>> I think that the problem might occur because the schema directory is
> >>> overwritten by wsdl2java in the second execution.
> >>
> >>
> >>
> >> Yes, if the outpath is same (.. -o ..) the generated schema folder
> >> will be overridden and cause the null pointer exception. Just give
> >> another location for service2.wsdl. That would do the trick.
> >>
> >> Saminda
> >>
> >>
> >
>
>
>



Re: [axis2] client for two web services - wsdl2java

Posted by Saminda Abeyruwan <sa...@opensource.lk>.
Hi Gordon,

There is a problem if you try to run muliple generted stubs within the 
same classpath due to "schema" folder. For the moment you have to run 
two stubs seperately. A JIRA has been opened this regard. Please track 
it down.

Saminda


Gordon Gekko wrote:

> Hi Saminda,
>
> first thanks a lot for your help!
>
> I don't exactly see what do you mean.  The wsdl2java -o option is in 
> both cases src, the source directory, where I want the code to be 
> generated.
>
> If I generate the code in two separate directories, let's say -o src1 
> and -o src2, then when I will compile the code in a common bin 
> directory.  The schema directory will still be overridden in the bin 
> directory because they have the same name.  On the other hand, I 
> cannot change the name of one of the two schema directories because 
> then it will not conform to the package name which is schema.system.foo.
>
> I also created two jar archives called schema1.jar and schema2.jar 
> where I put the schema directories generated by the different 
> executions of wsdl2java and made them available in the classpath.  But 
> this doesn't solve the problem, the same exceptions still arise.
>
> Maybe I didn't understand what you were suggesting.  What do you think?
>
> Thanks a lot again!
>
> Diego
>
>
>
> Saminda Abeyruwan wrote:
>
>> Gordon Gekko wrote:
>>
>>>
>>> I think that the problem might occur because the schema directory is
>>> overwritten by wsdl2java in the second execution.
>>
>>
>>
>> Yes, if the outpath is same (.. -o ..) the generated schema folder 
>> will be overridden and cause the null pointer exception. Just give 
>> another location for service2.wsdl. That would do the trick.
>>
>> Saminda
>>
>>
>


Re: [axis2] client for two web services - wsdl2java

Posted by Gordon Gekko <di...@tiscalinet.it>.
Hi Saminda,

first thanks a lot for your help!

I don't exactly see what do you mean.  The wsdl2java -o option is in 
both cases src, the source directory, where I want the code to be 
generated.

If I generate the code in two separate directories, let's say -o src1 
and -o src2, then when I will compile the code in a common bin 
directory.  The schema directory will still be overridden in the bin 
directory because they have the same name.  On the other hand, I cannot 
change the name of one of the two schema directories because then it 
will not conform to the package name which is schema.system.foo.

I also created two jar archives called schema1.jar and schema2.jar where 
I put the schema directories generated by the different executions of 
wsdl2java and made them available in the classpath.  But this doesn't 
solve the problem, the same exceptions still arise.

Maybe I didn't understand what you were suggesting.  What do you think?

Thanks a lot again!

Diego



Saminda Abeyruwan wrote:

> Gordon Gekko wrote:
> 
>>
>> I think that the problem might occur because the schema directory is
>> overwritten by wsdl2java in the second execution.
> 
> 
> Yes, if the outpath is same (.. -o ..) the generated schema folder will 
> be overridden and cause the null pointer exception. Just give another 
> location for service2.wsdl. That would do the trick.
> 
> Saminda
> 
> 

Re: [axis2] client for two web services - wsdl2java

Posted by Saminda Abeyruwan <sa...@opensource.lk>.
Gordon Gekko wrote:

>
> I think that the problem might occur because the schema directory is
> overwritten by wsdl2java in the second execution.

Yes, if the outpath is same (.. -o ..) the generated schema folder will 
be overridden and cause the null pointer exception. Just give another 
location for service2.wsdl. That would do the trick.

Saminda