Last modified by Pascal Robert on 2007/09/03 19:21

Show last authors
1 This documentation was written by Andrew Lindesay ([[http:~~/~~/www.lindesay.co.nz>>url:http://www.lindesay.co.nz||shape="rect"]]) in 2006 as part of supported code in the LEWOStuff framework, but this material has been transcribed here. It was written around the time of WebObjects 5.2 and 5.3 on the 1.4 JVM. WebServicesCore is the framework used in MacOS-X for communications with SOAP services vended on the internet. This page describes some problems that exist at the time of writing with getting WebServicesCore to communicate properly with WebObjects' WebServices framework.
2
3 == Multirefs ==
4
5 WebServicesCore does not appear to be able to process the 'multiref' values which are returned from the AXIS engine. To get around this, turn off multiref support in the WebObjects application. To achieve this, locate the {{code language="none"}}server.wsdd{{/code}} file and the element "{{code language="none"}}parameter{{/code}}" with the name "{{code language="none"}}sendMultiRefs{{/code}}". Modify this element to have the value "{{code language="none"}}false{{/code}}".
6
7 == Nil Serialisation ==
8
9 This is a very simple deserialiser that can be used to deserialise to {{code language="none"}}nil{{/code}}. Although this may seem less than useful, it proves very useful in the situation where you are using WebServicesCore which is a part of MacOS-X.
10
11 The WebServicesCore framework tends to serialise a {{code language="none"}}nil{{/code}} argument as {{code language="none"}}<xyz xsi:type="nil"/>{{/code}}. This is unfortunately missing type and so the SOAP engine is not able to instantiate the correct deserialiser for the type. The correct output would be {{code language="none"}}<xyz xsi:type="xsd:timeInstant" xsi:nil="true"/>{{/code}}, but it appears that it may be difficult to get WebServicesCore to do this.
12
13 Regardless of the inbound type however, this serialiser will be able to convert the poorly encoded {{code language="none"}}nil{{/code}} to {{code language="none"}}null{{/code}} in the java environment.
14
15 You can use the {{code language="none"}}registerWebServicesCoreNilDeserialiserFactoryForKnownTypes{{/code}} method on the class {{code language="none"}}LEWOWebServicesCoreNilDeserializerFactory{{/code}} to setup easily for common known classes.
16
17 {{code}}
18 package nz.co.lindesay.common.webobjects;
19
20 /*
21 ------------------------------------------------------------
22 LICENSE
23 ------------------------------------------------------------
24
25 Copyright (c) 2006, Andrew Lindesay
26 All rights reserved.
27
28 Redistribution and use in source and binary forms, with or
29 without modification, are permitted provided that the
30 following conditions are met:
31
32 * Redistributions of source code must retain the above
33 copyright notice, this list of conditions and the
34 following disclaimer.
35
36 * Redistributions in binary form must reproduce the above
37 copyright notice, this list of conditions and the
38 following disclaimer in the documentation and/or other
39 materials provided with the distribution.
40
41 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
42 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
43 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
44 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
45 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
46 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
48 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
49 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
50 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
51 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
52 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 SUCH DAMAGE.
55
56 ------------------------------------------------------------
57 */
58
59 /**
60 * <P>This is a <B>very</B> simple deserialiser that can be used
61 * to deserialise to <TT>nil</TT>. Although this may seem less
62 * than useful, it proves very useful in the situation where you
63 * are using WebServicesCore which is a part of MacOS-X.</P>
64 *
65 * <P>The WebServicesCore framework tends to serialise a <TT>nil</TT>
66 * argument as <TT><xyz xsi:type="nil"/></TT>. This is
67 * unfortunately missing type and so the SOAP engine is not able
68 * to instantiate the correct deserialiser for the type. The
69 * correct output would be <TT><xyz xsi:type="xsd:timeInstant" xsi:nil="true"/></TT>,
70 * but it appears that it may be difficult to get WebServicesCore
71 * to do this.</P>
72 *
73 * <P>Regardless of the inbound type however, this serialiser will
74 * be able to convert the poorly encoded <TT>nil</TT> to <TT>null</TT>
75 * in the java environment.</P>
76 *
77 * <P>You can use the <TT>registerWebServicesCoreNilDeserialiserFactoryForKnownTypes</TT>
78 * method on the class <TT>LEWOWebServicesCoreNilDeserializerFactory</TT>
79 * to setup easily for common known classes.</P>
80 */
81
82 public class LEWOWebServicesCoreNilDeserializer extends org.apache.axis.encoding.DeserializerImpl
83 {
84
85 // -------------------------------------------------
86
87 public LEWOWebServicesCoreNilDeserializer() { super(); }
88
89 // -------------------------------------------------
90
91 public Object getValue() { return null; }
92
93 // -------------------------------------------------
94
95 }
96 {{/code}}
97
98 {{code}}
99
100 package nz.co.lindesay.common.webobjects;
101
102 /*
103 ------------------------------------------------------------
104 LICENSE
105 ------------------------------------------------------------
106
107 Copyright (c) 2006, Andrew Lindesay
108 All rights reserved.
109
110 Redistribution and use in source and binary forms, with or
111 without modification, are permitted provided that the
112 following conditions are met:
113
114 * Redistributions of source code must retain the above
115 copyright notice, this list of conditions and the
116 following disclaimer.
117
118 * Redistributions in binary form must reproduce the above
119 copyright notice, this list of conditions and the
120 following disclaimer in the documentation and/or other
121 materials provided with the distribution.
122
123 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
124 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
125 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
126 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
127 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
128 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
129 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
130 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
131 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
132 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
133 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
134 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
135 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
136 SUCH DAMAGE.
137
138 ------------------------------------------------------------
139 */
140
141 import com.webobjects.foundation.*;
142 import com.webobjects.appserver.*;
143 import com.webobjects.eocontrol.*;
144
145 import javax.xml.namespace.*;
146
147 import java.util.*;
148
149 /**
150 * <P>See the class <TT>LEWOWebServicesCoreNilDeserializer</TT>
151 * for more details about this class.</P>
152 */
153
154 public class LEWOWebServicesCoreNilDeserializerFactory
155 implements org.apache.axis.encoding.DeserializerFactory
156 {
157 public final static String NAMESPACEURI_ANON = "http://anonuri/";
158
159 private Set mechanisms = null;
160
161 // -------------------------------------------------
162
163 /**
164 * <P>This method will setup the deserialiser for
165 * classes commonly encountered in development
166 * of web services. This is a quick-setup that
167 * might be invoked from the application setup.</P>
168 */
169
170 public static void registerWebServicesCoreNilDeserialiserFactoryForCommonClasses(String namespaceURI)
171 {
172 Set classesS = new HashSet();
173
174 classesS.add(NSTimestamp.class);
175 classesS.add(NSData.class);
176 classesS.add(EOGlobalID.class);
177 classesS.add(String.class);
178 classesS.add(Number.class);
179 classesS.add(Integer.class);
180 classesS.add(Float.class);
181 classesS.add(java.math.BigDecimal.class);
182 classesS.add(java.util.Date.class);
183
184 registerWebServicesCoreNilDeserialiserFactoryForClasses(classesS.iterator(),namespaceURI);
185 }
186
187 // -------------------------------------------------
188
189 /**
190 * <P>This method will setup the deserialiser for the
191 * classes supplied. This is a quick-setup that might
192 * be invoked from the application startup.</P>
193 */
194
195 public static void registerWebServicesCoreNilDeserialiserFactoryForClasses(Iterator classesI, String namespaceURI)
196 {
197 if(null==namespaceURI)
198 namespaceURI = NAMESPACEURI_ANON;
199
200 QName qn = new QName("http://anonuri/","nil");
201 LEWOWebServicesCoreNilDeserializerFactory factory = new LEWOWebServicesCoreNilDeserializerFactory();
202
203 while(classesI.hasNext())
204 WOWebServiceRegistrar.registerFactoriesForClassWithQName(
205 null,
206 factory,
207 (Class) classesI.next(),
208 qn);
209 }
210
211 // -------------------------------------------------
212
213 public LEWOWebServicesCoreNilDeserializerFactory() { super(); }
214
215 // -------------------------------------------------
216
217 public javax.xml.rpc.encoding.Deserializer getDeserializerAs(String mechanismType)
218 { return new LEWOWebServicesCoreNilDeserializer(); }
219
220 // -------------------------------------------------
221
222 public Iterator getSupportedMechanismTypes()
223 {
224 if(null==mechanisms)
225 {
226 mechanisms = new HashSet();
227 mechanisms.add(org.apache.axis.Constants.AXIS_SAX);
228 }
229
230 return mechanisms.iterator();
231 }
232
233 // -------------------------------------------------
234
235 }
236
237 {{/code}}