Using SOAP complex types with OfBiz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Using SOAP complex types with OfBiz

Michael Imhof
After a while a found a way to create and process SOAP request
with complex types in OfBiz:

1). Use Java2WSDL to create a WSDL. This allows you to use complex types.
    javac: Compile the class with option -g to get debug infos (e.g. real argument names instead of arg0, arg1,...)
    Java2WSDL: Use parameter -A OPERATION.

2). Property: axis.doAutoTypes should be true. If not, no serializer could be found.
     I put this in Start.java:
       System.setProperty("axis.doAutoTypes", Boolean.TRUE.toString());

3). The complex type class should implement:
           public static org.apache.axis.description.TypeDesc getTypeDesc():
     For a class ComplexType with a string attribute <name>, TypeDesc should look like this:

     org.apache.axis.description.TypeDesc typeDesc =new org.apache.axis.description.TypeDesc(ComplexTest.class, true);
     typeDesc.setXmlType(new javax.xml.namespace.QName("http://types.archiv.isgate.nowhow.ch", "ComplexTest"));
     org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
     elemField.setFieldName("name");
     elemField.setXmlName(new javax.xml.namespace.QName("", "name"));
     elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
     typeDesc.addFieldDesc(elemField);

Now you can generate Services with a complex type ComplexType.
    <service name="testService" engine="java" location="ch.nowhow.isgate.archiv.ArchivServices"
        invoke="testService" export="true">
        <namespace>http://nowhow.ch/isgate/</namespace>
        <attribute name="inList" type="ch.nowhow.isgate.archiv.types.ComplexTest" mode="IN"
            optional="false"/>
    </service>

If you want to use arrays of complex types (or simply array of string),
you should enhance ObjectType.java to support arrays...but this is another story and
I'm still testing my changes (https://issues.apache.org/jira/browse/OFBIZ-746):-)

Regards
Michael
Reply | Threaded
Open this post in threaded view
|

Re: Using SOAP complex types with OfBiz

siddhartha-2
Hello All ,

I tried the same with ofbiz R 607122 . I first created the wsdl using Java2WSDL . Then I tried
to access the deployed webservice :

My service def looks like the following :

<service name="createHelloPerson" engine="java"
   location="org.ofbiz.hello3.Hello3Services" invoke="createHelloPerson" export="true">
        <description>Create a HelloPerson</description> 
                  <namespace>http://home.com</namespace>       
                <attribute name="personTwo" mode="IN" type="org.ofbiz.hello3.ComplexTest" optional="true"/>                            </service>

my SoapMessage :

<soap:Body>
<createHelloPerson>
<personTwo xsi:type=\"xsd:complexType\">
<name xsi:type=\"xsd:attribute\">peters</name>
</personTwo></createHelloPerson></soap:Body></soap:Envelope>

Can any Body tell me whether I am using the proper soap message or not?As I am getting the following
exception

 [     RequestHandler.java:314:
ERROR] Request SOAPService caused an error with the following message: Error calling
event: org.ofbiz.webapp.event.EventHandlerException: org.xml.sax.SAXException (org.xm
l.sax.SAXException)


thx in advance
SiddharthaC



Michael Imhof wrote
After a while a found a way to create and process SOAP request
with complex types in OfBiz:

1). Use Java2WSDL to create a WSDL. This allows you to use complex types.
    javac: Compile the class with option -g to get debug infos (e.g. real argument names instead of arg0, arg1,...)
    Java2WSDL: Use parameter -A OPERATION.

2). Property: axis.doAutoTypes should be true. If not, no serializer could be found.
     I put this in Start.java:
       System.setProperty("axis.doAutoTypes", Boolean.TRUE.toString());

3). The complex type class should implement:
           public static org.apache.axis.description.TypeDesc getTypeDesc():
     For a class ComplexType with a string attribute <name>, TypeDesc should look like this:

     org.apache.axis.description.TypeDesc typeDesc =new org.apache.axis.description.TypeDesc(ComplexTest.class, true);
     typeDesc.setXmlType(new javax.xml.namespace.QName("http://types.archiv.isgate.nowhow.ch", "ComplexTest"));
     org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
     elemField.setFieldName("name");
     elemField.setXmlName(new javax.xml.namespace.QName("", "name"));
     elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
     typeDesc.addFieldDesc(elemField);

Now you can generate Services with a complex type ComplexType.
    <service name="testService" engine="java" location="ch.nowhow.isgate.archiv.ArchivServices"
        invoke="testService" export="true">
        <namespace>http://nowhow.ch/isgate/</namespace>
        <attribute name="inList" type="ch.nowhow.isgate.archiv.types.ComplexTest" mode="IN"
            optional="false"/>
    </service>

If you want to use arrays of complex types (or simply array of string),
you should enhance ObjectType.java to support arrays...but this is another story and
I'm still testing my changes (https://issues.apache.org/jira/browse/OFBIZ-746):-)

Regards
Michael
Reply | Threaded
Open this post in threaded view
|

Re: Using SOAP complex types with OfBiz

Jacques Le Roux
Administrator
http://docs.ofbiz.org/display/OFBIZ/FAQ+-+Tips+-+Tricks+-+Cookbook+-+HowTo#FAQ-Tips-Tricks-Cookbook-HowTo-Soap

Jacques

From: "siddhartha" <[hidden email]>

>
> Hello All ,
>
> I tried the same with ofbiz R 607122 . I first created the wsdl using
> Java2WSDL . Then I tried
> to access the deployed webservice :
>
> My service def looks like the following :
>
> <service name="createHelloPerson" engine="java"
>   location="org.ofbiz.hello3.Hello3Services" invoke="createHelloPerson"
> export="true">
>        <description>Create a HelloPerson</description>
>   <namespace>http://home.com</namespace>        
> <attribute name="personTwo" mode="IN" type="org.ofbiz.hello3.ComplexTest"
> optional="true"/>     </service>
>
> my SoapMessage :
>
> <soap:Body>
> <createHelloPerson>
> <personTwo xsi:type=\"xsd:complexType\">
> <name xsi:type=\"xsd:attribute\">peters</name>
> </personTwo></createHelloPerson></soap:Body></soap:Envelope>
>
> Can any Body tell me whether I am using the proper soap message or not?As I
> am getting the following
> exception
>
> [     RequestHandler.java:314:
> ERROR] Request SOAPService caused an error with the following message: Error
> calling
> event: org.ofbiz.webapp.event.EventHandlerException:
> org.xml.sax.SAXException (org.xm
> l.sax.SAXException)
>
> thx in advance
> SiddharthaC
>
>
>
>
> Michael Imhof wrote:
>>
>> After a while a found a way to create and process SOAP request
>> with complex types in OfBiz:
>>
>> 1). Use Java2WSDL to create a WSDL. This allows you to use complex types.
>>     javac: Compile the class with option -g to get debug infos (e.g. real
>> argument names instead of arg0, arg1,...)
>>     Java2WSDL: Use parameter -A OPERATION.
>>
>> 2). Property: axis.doAutoTypes should be true. If not, no serializer could
>> be found.
>>      I put this in Start.java:
>>        System.setProperty("axis.doAutoTypes", Boolean.TRUE.toString());
>>
>> 3). The complex type class should implement:
>>            public static org.apache.axis.description.TypeDesc
>> getTypeDesc():
>>      For a class ComplexType with a string attribute <name>, TypeDesc
>> should look like this:
>>
>>      org.apache.axis.description.TypeDesc typeDesc =new
>> org.apache.axis.description.TypeDesc(ComplexTest.class, true);
>>      typeDesc.setXmlType(new
>> javax.xml.namespace.QName("http://types.archiv.isgate.nowhow.ch",
>> "ComplexTest"));
>>      org.apache.axis.description.ElementDesc elemField = new
>> org.apache.axis.description.ElementDesc();
>>      elemField.setFieldName("name");
>>      elemField.setXmlName(new javax.xml.namespace.QName("", "name"));
>>      elemField.setXmlType(new
>> javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
>>      typeDesc.addFieldDesc(elemField);
>>
>> Now you can generate Services with a complex type ComplexType.
>>     <service name="testService" engine="java"
>> location="ch.nowhow.isgate.archiv.ArchivServices"
>>         invoke="testService" export="true">
>>         <namespace>http://nowhow.ch/isgate/</namespace>
>>         <attribute name="inList"
>> type="ch.nowhow.isgate.archiv.types.ComplexTest" mode="IN"
>>             optional="false"/>
>>     </service>
>>
>> If you want to use arrays of complex types (or simply array of string),
>> you should enhance ObjectType.java to support arrays...but this is another
>> story and
>> I'm still testing my changes
>> (https://issues.apache.org/jira/browse/OFBIZ-746):-)
>>
>> Regards
>> Michael
>>
>
> --
> View this message in context: http://www.nabble.com/Using-SOAP-complex-types-with-OfBiz-tp9180865p17886201.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Using SOAP complex types with OfBiz

Michael Imhof
In reply to this post by siddhartha-2
Hi SiddharthaC,

looks like you're using the wrong binding. I use the following parameters to generate my
wsdl with Java2WSDL:
-A OPERATION
-y WRAPPED
-u LITERAL

Regards
Michael


siddhartha wrote
Hello All ,

I tried the same with ofbiz R 607122 . I first created the wsdl using Java2WSDL . Then I tried
to access the deployed webservice :

My service def looks like the following :

<service name="createHelloPerson" engine="java"
   location="org.ofbiz.hello3.Hello3Services" invoke="createHelloPerson" export="true">
        <description>Create a HelloPerson</description> 
                  <namespace>http://home.com</namespace>       
                <attribute name="personTwo" mode="IN" type="org.ofbiz.hello3.ComplexTest" optional="true"/>                            </service>

my SoapMessage :

<soap:Body>
<createHelloPerson>
<personTwo xsi:type=\"xsd:complexType\">
<name xsi:type=\"xsd:attribute\">peters</name>
</personTwo></createHelloPerson></soap:Body></soap:Envelope>

Can any Body tell me whether I am using the proper soap message or not?As I am getting the following
exception

 [     RequestHandler.java:314:
ERROR] Request SOAPService caused an error with the following message: Error calling
event: org.ofbiz.webapp.event.EventHandlerException: org.xml.sax.SAXException (org.xm
l.sax.SAXException)


thx in advance
SiddharthaC



Michael Imhof wrote
After a while a found a way to create and process SOAP request
with complex types in OfBiz:

1). Use Java2WSDL to create a WSDL. This allows you to use complex types.
    javac: Compile the class with option -g to get debug infos (e.g. real argument names instead of arg0, arg1,...)
    Java2WSDL: Use parameter -A OPERATION.

2). Property: axis.doAutoTypes should be true. If not, no serializer could be found.
     I put this in Start.java:
       System.setProperty("axis.doAutoTypes", Boolean.TRUE.toString());

3). The complex type class should implement:
           public static org.apache.axis.description.TypeDesc getTypeDesc():
     For a class ComplexType with a string attribute <name>, TypeDesc should look like this:

     org.apache.axis.description.TypeDesc typeDesc =new org.apache.axis.description.TypeDesc(ComplexTest.class, true);
     typeDesc.setXmlType(new javax.xml.namespace.QName("http://types.archiv.isgate.nowhow.ch", "ComplexTest"));
     org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
     elemField.setFieldName("name");
     elemField.setXmlName(new javax.xml.namespace.QName("", "name"));
     elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
     typeDesc.addFieldDesc(elemField);

Now you can generate Services with a complex type ComplexType.
    <service name="testService" engine="java" location="ch.nowhow.isgate.archiv.ArchivServices"
        invoke="testService" export="true">
        <namespace>http://nowhow.ch/isgate/</namespace>
        <attribute name="inList" type="ch.nowhow.isgate.archiv.types.ComplexTest" mode="IN"
            optional="false"/>
    </service>

If you want to use arrays of complex types (or simply array of string),
you should enhance ObjectType.java to support arrays...but this is another story and
I'm still testing my changes (https://issues.apache.org/jira/browse/OFBIZ-746):-)

Regards
Michael
Reply | Threaded
Open this post in threaded view
|

Re: Using SOAP complex types with OfBiz

Alfredo Rueda
In reply to this post by Michael Imhof
Hello Michael!

Have you manage to handle arrays of objects as output parameters of an ofbiz service exported via soap?

Thank you very much!

Alfredo

Michael Imhof wrote
After a while a found a way to create and process SOAP request
with complex types in OfBiz:

1). Use Java2WSDL to create a WSDL. This allows you to use complex types.
    javac: Compile the class with option -g to get debug infos (e.g. real argument names instead of arg0, arg1,...)
    Java2WSDL: Use parameter -A OPERATION.

2). Property: axis.doAutoTypes should be true. If not, no serializer could be found.
     I put this in Start.java:
       System.setProperty("axis.doAutoTypes", Boolean.TRUE.toString());

3). The complex type class should implement:
           public static org.apache.axis.description.TypeDesc getTypeDesc():
     For a class ComplexType with a string attribute <name>, TypeDesc should look like this:

     org.apache.axis.description.TypeDesc typeDesc =new org.apache.axis.description.TypeDesc(ComplexTest.class, true);
     typeDesc.setXmlType(new javax.xml.namespace.QName("http://types.archiv.isgate.nowhow.ch", "ComplexTest"));
     org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
     elemField.setFieldName("name");
     elemField.setXmlName(new javax.xml.namespace.QName("", "name"));
     elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
     typeDesc.addFieldDesc(elemField);

Now you can generate Services with a complex type ComplexType.
    <service name="testService" engine="java" location="ch.nowhow.isgate.archiv.ArchivServices"
        invoke="testService" export="true">
        <namespace>http://nowhow.ch/isgate/</namespace>
        <attribute name="inList" type="ch.nowhow.isgate.archiv.types.ComplexTest" mode="IN"
            optional="false"/>
    </service>

If you want to use arrays of complex types (or simply array of string),
you should enhance ObjectType.java to support arrays...but this is another story and
I'm still testing my changes (https://issues.apache.org/jira/browse/OFBIZ-746):-)

Regards
Michael
Reply | Threaded
Open this post in threaded view
|

Re: Using SOAP complex types with OfBiz

Michael Imhof
Hi Alfredo,

we're using successfully arrays of objects in SOAP services.
The ObjectType.class in the trunk should support arrays (https://issues.apache.org/jira/browse/OFBIZ-1008).

This should work for simple data types. If you're using complex types then it will be more
complicated because you have to register the BeanSerializer/BeanDeserializer for the type.
Set a breakpoint in the method SOAPEventHandler.invoke(..) and try to understand what
happens there...

Regards,
Michael


Alfredo Rueda wrote
Hello Michael!

Have you manage to handle arrays of objects as output parameters of an ofbiz service exported via soap?

Thank you very much!

Alfredo

Michael Imhof wrote
After a while a found a way to create and process SOAP request
with complex types in OfBiz:

1). Use Java2WSDL to create a WSDL. This allows you to use complex types.
    javac: Compile the class with option -g to get debug infos (e.g. real argument names instead of arg0, arg1,...)
    Java2WSDL: Use parameter -A OPERATION.

2). Property: axis.doAutoTypes should be true. If not, no serializer could be found.
     I put this in Start.java:
       System.setProperty("axis.doAutoTypes", Boolean.TRUE.toString());

3). The complex type class should implement:
           public static org.apache.axis.description.TypeDesc getTypeDesc():
     For a class ComplexType with a string attribute <name>, TypeDesc should look like this:

     org.apache.axis.description.TypeDesc typeDesc =new org.apache.axis.description.TypeDesc(ComplexTest.class, true);
     typeDesc.setXmlType(new javax.xml.namespace.QName("http://types.archiv.isgate.nowhow.ch", "ComplexTest"));
     org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
     elemField.setFieldName("name");
     elemField.setXmlName(new javax.xml.namespace.QName("", "name"));
     elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
     typeDesc.addFieldDesc(elemField);

Now you can generate Services with a complex type ComplexType.
    <service name="testService" engine="java" location="ch.nowhow.isgate.archiv.ArchivServices"
        invoke="testService" export="true">
        <namespace>http://nowhow.ch/isgate/</namespace>
        <attribute name="inList" type="ch.nowhow.isgate.archiv.types.ComplexTest" mode="IN"
            optional="false"/>
    </service>

If you want to use arrays of complex types (or simply array of string),
you should enhance ObjectType.java to support arrays...but this is another story and
I'm still testing my changes (https://issues.apache.org/jira/browse/OFBIZ-746):-)

Regards
Michael
Reply | Threaded
Open this post in threaded view
|

Re: Using SOAP complex types with OfBiz

Alfredo Rueda
Hi Michael,

I'm sorry but I'm a bit confused.
I don't know how to relate the instructions that you provided in the first post to accomplish the task of passing an object as a parameter with the ones that you are pointing now to return an array of objects.
In order to return an array of objects, Should I still follow the instructions that you provided in the first place?
If so, would you be so kind of provide an extended version of the instructions, please?
Thank you very much
Michael Imhof wrote
Hi Alfredo,

we're using successfully arrays of objects in SOAP services.
The ObjectType.class in the trunk should support arrays (https://issues.apache.org/jira/browse/OFBIZ-1008).

This should work for simple data types. If you're using complex types then it will be more
complicated because you have to register the BeanSerializer/BeanDeserializer for the type.
Set a breakpoint in the method SOAPEventHandler.invoke(..) and try to understand what
happens there...

Regards,
Michael


Alfredo Rueda wrote
Hello Michael!

Have you manage to handle arrays of objects as output parameters of an ofbiz service exported via soap?

Thank you very much!

Alfredo

Michael Imhof wrote
After a while a found a way to create and process SOAP request
with complex types in OfBiz:

1). Use Java2WSDL to create a WSDL. This allows you to use complex types.
    javac: Compile the class with option -g to get debug infos (e.g. real argument names instead of arg0, arg1,...)
    Java2WSDL: Use parameter -A OPERATION.

2). Property: axis.doAutoTypes should be true. If not, no serializer could be found.
     I put this in Start.java:
       System.setProperty("axis.doAutoTypes", Boolean.TRUE.toString());

3). The complex type class should implement:
           public static org.apache.axis.description.TypeDesc getTypeDesc():
     For a class ComplexType with a string attribute <name>, TypeDesc should look like this:

     org.apache.axis.description.TypeDesc typeDesc =new org.apache.axis.description.TypeDesc(ComplexTest.class, true);
     typeDesc.setXmlType(new javax.xml.namespace.QName("http://types.archiv.isgate.nowhow.ch", "ComplexTest"));
     org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
     elemField.setFieldName("name");
     elemField.setXmlName(new javax.xml.namespace.QName("", "name"));
     elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
     typeDesc.addFieldDesc(elemField);

Now you can generate Services with a complex type ComplexType.
    <service name="testService" engine="java" location="ch.nowhow.isgate.archiv.ArchivServices"
        invoke="testService" export="true">
        <namespace>http://nowhow.ch/isgate/</namespace>
        <attribute name="inList" type="ch.nowhow.isgate.archiv.types.ComplexTest" mode="IN"
            optional="false"/>
    </service>

If you want to use arrays of complex types (or simply array of string),
you should enhance ObjectType.java to support arrays...but this is another story and
I'm still testing my changes (https://issues.apache.org/jira/browse/OFBIZ-746):-)

Regards
Michael
Reply | Threaded
Open this post in threaded view
|

Re: Using SOAP complex types with OfBiz

Michael Imhof
Please try to develop SOAP service calls step by step. It seems to me that you're searching for
a overall solution wich I can't provide because it's too complicated (too many classes involved and
our OfBiz version is 2years old!!).

1) Are you able to generate WSDL-Files out of ofbiz service definitions? The generated WSDL-Files should be WS-I conformant to make sure the're working with C++, .NET, etc Clients.
If you're not able to generate the WSDL Files, have a look at Java2WSDL from Axis.

2) Are you able to call an ofbiz SOAP service from outside of Ofbiz?
I'm testing my SOAP services over a .NET client.

3) Are you able to call an ofbiz SOAP service with complex types?

If you reach this point and you're able to call SOAP services with complex types, then the array
should work too. (This is only a guess because I'm far away from the current (trunk) release
of Ofbiz).

Just try to break down the problem in smaller problems then I will be probably able to help...

Regards
Michael