Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Web Service Array of String

661 views
Skip to first unread message

D. Vandeputte

unread,
Feb 17, 2010, 8:55:37 AM2/17/10
to
Hi!

I have again a question about the web services!! :)

I want to pass array of string to the web service. I have edited the
wsdl to define a complexType. Here is a part of the wsdl file :

<wsdl:definitions name="alCustomerWS_definitionName"
targetNamespace="ns:alCustomerWS_thisNamespace"
xmlns:tns="ns:alCustomerWS_thisNamespace" xmlns:xsd="http

://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/
wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd1="http://www.fortis.c

om/schema">
<wsdl:types>
<s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.fortis.com/schema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">

<s:complexType name="ArrayOfString">
<s:complexContent>
<s:restriction base="soapenc:Array">
<s:attribute ref="soapenc:arrayType"
wsdl:arrayType="s:string[]"/>
</s:restriction>
</s:complexContent>
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="alCustomerWSResponse">
</wsdl:message>
<wsdl:message name="UpdateResponse">
<wsdl:part name="result" type="xsd:string">
</wsdl:part>
</wsdl:message>
<wsdl:message name="UpdateRequest">
<wsdl:part name="customer" type="xsd:string">
</wsdl:part>
<wsdl:part name="groupsToAdd" type="xsd1:ArrayOfString">
</wsdl:part>
<wsdl:part name="groupsToRemove" type="xsd1:ArrayOfString">
</wsdl:part>
</wsdl:message>
...

But I can get it working within TDI :(( Do I have to define
complexType in the SoapTojava Function ? If it's the case, how do I
define it ? Do I need to use the ComplexTypeGenerator ?

Thanks!!!

Didier

flamesnm

unread,
Feb 17, 2010, 12:14:34 PM2/17/10
to
HI Didier

As soon as you start using complex types, then the complex type
generator is your friend. It converts the complex type into a java
object that you can manipulate in your code. I posted an answer to a
similar question here:
http://groups.google.co.uk/group/ibm.software.network.directory-integrator/browse_thread/thread/8fedae50663d7677/55ca9afd9a0d1403#55ca9afd9a0d1403


D. Vandeputte

unread,
Feb 18, 2010, 3:19:04 AM2/18/10
to
Hi!

When I run the ComplexTypeGenerator, I get 4 classes generated, but no
one with a type definition :
- ALCustomerWS_definitionNameBindingStub.java
- ALCustomerWS_definitionNamePortType.java
- ALCustomerWS_definitionNameService.java
- ALCustomerWS_definitionNameServiceLocator.java

Is there somthing missing in the type definition in the wsdl ?

By the way, here is the soap message send by the client :
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schem
as.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/
XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Body>
<ns1:Update soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/
encoding/" xmlns:ns1="http://ws.fortis.com">
<customer xsi:type="xsd:string">TEST-CUSTOMER</customer>
<groupsToAdd href="#id0"/>
<groupsToRemove xsi:type="xsd:string">GRP TO REMOVE</
groupsToRemove>
</ns1:Update>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://
schemas.xmlsoap.org/soap/encoding/"
soapenc:arrayType="ns2:ArrayOfString[2]" xsi:type="soapenc:Array"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns2="http://ws.fortis.com">
<multiRef xsi:type="xsd:string">GRP1</multiRef>
<multiRef xsi:type="xsd:string">GRP2</multiRef>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>

And here is the error on the server side :

09:12:16 ERROR - [Update_SoapToJava]
Exception:org.xml.sax.SAXException: No deserializer defined for array
type {http://ws.fortis.com}ArrayOfString

09:12:16 INFO - [Update_SoapToJava] CTGDIS495I handleException ,
functioncall, org.xml.sax.SAXException: No deserializer defined for
array type {http://ws.fortis.com}ArrayOfString


Any idea of what going wrong ?? :/


Thanks very much for your help!

Didier

Deyan Popov

unread,
Feb 18, 2010, 4:16:36 AM2/18/10
to
Try to put this script in the "After Initialze" hook of the Axis Soap
to Java Function Component:

var javaType = java.lang.Class.forName("[Ljava.lang.String;");
var xmlType = new javax.xml.namespace.QName("http://www.fortis.com/
schema", "ArrayOfString");
var serializerFactory = new
org.apache.axis.encoding.ser.ArraySerializerFactory(xmlType, null);
var deserializerFactory = new
org.apache.axis.encoding.ser.ArrayDeserializerFactory();
thisConnector.getFunction().registerTypeMapping(javaType, xmlType,
serializerFactory, deserializerFactory);

Btw if you have control over the WSDL (i.e. write it yourself and not
get it from somewhere), you really should not use SOAP encoding but
document/literal WSDL style instead.

Regards,
Deyan Popov

D. Vandeputte

unread,
Feb 18, 2010, 4:31:14 AM2/18/10
to
I have the control over the wsdl file, but it's the first time I have
to write one! :/ (that's why I was using the generator...)

If I do the conversion to document/literal, do I still need to put the
script you send me ?

Didier

Deyan Popov

unread,
Feb 18, 2010, 5:01:52 AM2/18/10
to
The script is only needed if you use SOAP encoding.
SOAP encoding is frowned upon these days, because it is hard to use
and creates interoperability problems:
http://www.ws-i.org/Profiles/BasicProfile-1.1.html#SOAP_encodingStyle_Attribute

If everything is under your control you should probably try the latest
standards in the WS-* camp - WSDL 2.0 and SOAP 1.2 and the new Axis2
web service components (see <install dir>/examples/
axis2_web_services). These components rely on a different approach
than the old ones, so you should go through the Reference guide first:
http://publib.boulder.ibm.com/infocenter/tivihelp/v2r1/index.jsp?topic=/com.ibm.IBMDI.doc_7.0/referenceguide14.htm
http://publib.boulder.ibm.com/infocenter/tivihelp/v2r1/index.jsp?topic=/com.ibm.IBMDI.doc_7.0/referenceguide99.htm

The Axis2 components don't use generation of Java code for complex
types, but instead rely on the new hierarchical features added to the
com.ibm.di.entry.Entry class in TDI 7.0:
http://publib.boulder.ibm.com/infocenter/tivihelp/v2r1/index.jsp?topic=/com.ibm.IBMDI.doc_7.0/tdihierarchicalentryobjects.htm
It would be really helpful if you have some knowledge of the DOM API:
http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/Document.html

Also you should get the latest fix pack for 7.0 because I think there
were some fixes for the Axis2 components.

As an alternative to WS-* web services you could use REST. Leaving the
hype aside, REST has real practical advantages. (Here is one
interesting rant about distributed systems by an old time guru:
http://www.infoq.com/presentations/vinoski-rpc-convenient-but-flawed)
For REST you could use the HTTP Server Connector combined with the new
XML Parser (which also uses heavily the new hierarchical features of
the Entry).

Regards,
Deyan Popov

D. Vandeputte

unread,
Feb 18, 2010, 5:11:18 AM2/18/10
to
Once again, thank you very much for all those info!

I will have a look to those links right now!

I will keep you informed! :)

Didier

D. Vandeputte

unread,
Feb 19, 2010, 2:20:38 AM2/19/10
to
Hi!
Since yesterday, I'm trying to get the axis2_web_services example to
work :((
This script doesn't seems to work and I don't understand why :
// assembles a request to the server, consisting of a book object
// with two elements - title and author

var attr = work.createElementNS("http://www.example.com/library/",
"book");
var child1 = work.createElement("title");
var child2 = work.createElement("author");
child1.appendChild(work.createTextNode(work.title));
child2.appendChild(work.createTextNode(work.author));
attr.appendChild(child1);
attr.appendChild(child2);
work.setAttribute(attr);

var header = work.createElement("$soapHeader");
var requestTime = java.lang.System.currentTimeMillis();
header.appendChild(work.createTextNode(requestTime));
work.setAttribute(header);

task.logmsg("<<<<<<<<<< Request = " + work.getAttribute("book"));

Log file result :

08:19:01 INFO - [FileSystemConnector] CTGDIS506I The 'work' object
08:19:01 INFO - [FileSystemConnector] CTGDIS003I *** Start dumping
Entry
08:19:01 INFO - Operation: generic
08:19:01 INFO - Entry attributes:
08:19:01 INFO - author (replace): 'Asimov'
08:19:01 INFO - title (replace): 'I Robot'
08:19:01 INFO - [FileSystemConnector] CTGDIS004I *** Finished dumping
Entry
08:19:01 INFO - <<<<<<<<<< Request =
08:19:01 INFO - [Axis2WebServiceClientFunctionComponent] CTGDIS504I
*Result of attribute mapping*
08:19:01 INFO - [Axis2WebServiceClientFunctionComponent] CTGDIS505I
The 'conn' object
08:19:01 INFO - [Axis2WebServiceClientFunctionComponent] CTGDIS003I
*** Start dumping Entry
08:19:01 INFO - Operation: generic
08:19:01 INFO - Entry attributes:
08:19:01 INFO - book (replace):
08:19:01 INFO - $soapHeader (replace):
'1266563941405'
08:19:01 INFO - [Axis2WebServiceClientFunctionComponent] CTGDIS004I
*** Finished dumping Entry

Can anybody tell me why the book attribute is empty ??? o_O

Thanks!

Didier

Deyan Popov

unread,
Feb 19, 2010, 3:54:55 AM2/19/10
to
There might be a bug somewhere. All problems with the Axis2 example
should have been fixed in APAR IO11117:
http://www-01.ibm.com/support/docview.wss?rs=697&context=SSCQGF&dc=DB550&uid=swg1IO11117&loc=en_US&cs=utf-8&lang=en
Please contact support to see what their explanation would be.

Regards,
Deyan Popov

D. Vandeputte

unread,
Feb 19, 2010, 3:59:34 AM2/19/10
to
Ok! I'm already in touch with the support for this issue, so I will
keep you informed! ;)

Didier

On 19 Feb, 09:54, Deyan Popov <deyan.po...@gmail.com> wrote:
> There might be a bug somewhere. All problems with the Axis2 example

> should have been fixed in APAR IO11117:http://www-01.ibm.com/support/docview.wss?rs=697&context=SSCQGF&dc=DB...

0 new messages