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
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
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
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
If I do the conversion to document/literal, do I still need to put the
script you send me ?
Didier
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
I will have a look to those links right now!
I will keep you informed! :)
Didier
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
Regards,
Deyan Popov
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...