Re: WebServices Material on Wiki
Re: WebServices Material on Wiki
- Subject: Re: WebServices Material on Wiki
- From: Andrew Lindesay <email@hidden>
- Date: Fri, 19 Jan 2007 08:33:15 +1300
Hello Francis;
I have found my original description of the issue and have
transcribed that to the wiki as well. Here is the body of this text.
=====================
I am building a graph of inserted/modified/referenced EO-s in the
session's default EC and then persisting the changes. In order to
reference inserted objects in the EC to create relationships between
in-memory EO-s, I am referring to them using their temporary
EOGlobalID's. For example...
boolean addFoo(
String wosid,
String name,
String code,
EOGobalID barGlobalID)
...where 'barGID' may be a temporary GID (EOTemporaryGlobalID) or may
be a key GID (EOKeyGlobalID). The temporary GID's are serialising
out to the client from the WO application without any difficulty. In
this case, the XML chunk in the SOAP envelope looks like this...
<barGlobalID xsi:type="ns4:EOGlobalID">
<data xsi:type="xsd:base64Binary">AAB/
AAABAAAXcQEAAAABC8pbeE6Acu4F</data>
</barGlobalID>
However when I try and use this temporary GID by sending it from the
client, back into the WO application for deserialisation, I end up
sending this...
<barGlobalID xsi:type="SOAP-ENC:Dictionary">
<data xsi:type="xsd:base64Binary"> AAB/
AAABAAAXcQEAAAABC8pbeE6Acu4F</data>
</barGlobalID>
[I am using Apple's WebServicesCore framework and I'm not entirely
sure why it is putting whitespace into the base64 encoding, but I
have done independent tests which would tend to indicate that this is
deserialised correctly by the deserialiser on the WO/AXIS end.]
Passing in 'null' for this argument results in no exception, passing
in a temporary GID 'dictionary structure' as shown above produced the
following exception and corresponding AXIS fault as shown below...
- IllegalArgumentException:
java.lang.IllegalArgumentException
at sun.reflect.UnsafeObjectFieldAccessorImpl.set
(UnsafeObjectFieldAccessorImpl.java:63)
at java.lang.reflect.Field.set(Field.java:519)
at org.apache.axis.encoding.FieldTarget.set(FieldTarget.java:91)
at org.apache.axis.encoding.DeserializerImpl.valueComplete
(DeserializerImpl.java:282)
at org.apache.axis.encoding.DeserializerImpl.endElement
(DeserializerImpl.java:541)
at org.apache.axis.encoding.DeserializationContextImpl.endElement
(DeserializationContextImpl.java:1015)
at org.apache.axis.message.SAX2EventRecorder.replay
(SAX2EventRecorder.java:204)
at org.apache.axis.message.MessageElement.publishToHandler
(MessageElement.java:722)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:
233)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)
at org.apache.axis.providers.java.RPCProvider.processMessage
(RPCProvider.java:184)
at org.apache.axis.providers.java.JavaProvider.invoke
(JavaProvider.java:333)
at org.apache.axis.strategies.InvocationStrategy.visit
(InvocationStrategy.java:71)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
at org.apache.axis.handlers.soap.SOAPService.invoke
(SOAPService.java:481)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:323)
at
com.webobjects.appserver._private.WOWebService.performActionNamed
(WOWebService.java:375)
If I send a key GID as follows...
<barGlobalID xsi:type="SOAP-ENC:Dictionary">
<primaryKeys SOAP-ENC:arrayType="xsd:anyType[1]" xsi:type="SOAP-
ENC:Array">
<item_0 xsi:type="xsd:int">1</item_0>
</primaryKeys>
<entityName xsi:type="xsd:string">BarEntity</entityName>
</barGlobalID>
...then it deserialises without issue. When I try to get a WSDL from
a registered web service that has EOGlobalID's as parameters, I tend
to get the following exception and corresponding AXIS fault. For
this reason it is not possible to find out how the EOGlobalID should
be communicated.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>WSDLException: faultCode=OTHER_ERROR: Can't
find prefix for 'http://www.apple.com/webobjects/webservices/
soap/'. Namespace prefixes must be set on the Definition
object using the addNamespace(...) method.: </faultstring>
<detail>
<ns1:stackTrace xmlns:ns1="http://xml.apache.org/
axis/">WSDLException: faultCode=OTHER_ERROR: Can't find prefix
for 'http://www.apple.com/webobjects/webservices/soap/'.
Namespace prefixes must be set on the Definition object using the
addNamespace(...) method.:
at com.ibm.wsdl.util.xml.DOMUtils.getPrefix(Unknown Source)
at com.ibm.wsdl.util.xml.DOMUtils.getQualifiedValue(Unknown Source)
at com.ibm.wsdl.util.xml.DOMUtils.printQualifiedAttribute(Unknown
Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.printParts(Unknown Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.printMessages(Unknown Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.printDefinition(Unknown Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.writeWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.getDocument(Unknown Source)
at org.apache.axis.wsdl.fromJava.Emitter.emit(Emitter.java:267)
at org.apache.axis.providers.java.JavaProvider.generateWSDL
(JavaProvider.java:494)
at org.apache.axis.strategies.WSDLGenStrategy.visit
(WSDLGenStrategy.java:72)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
at org.apache.axis.SimpleChain.generateWSDL(SimpleChain.java:137)
at org.apache.axis.handlers.soap.SOAPService.generateWSDL
(SOAPService.java:375)
at org.apache.axis.server.AxisServer.generateWSDL(AxisServer.java:
499)
at
com.webobjects.appserver._private.WOWebService.performActionNamed
(WOWebService.java:352)
at
com.webobjects.appserver._private.WOActionRequestHandler._handleReques
t(WOActionRequestHandler.java:240)
at
com.webobjects.appserver._private.WOActionRequestHandler.handleRequest
(WOActionRequestHandler.java:142)
at
com.webobjects.appserver._private.WOWebServiceRequestHandler.handleReq
uest(WOWebServiceRequestHandler.java:95)
at com.webobjects.appserver.WOApplication.dispatchRequest
(WOApplication.java:1306)
at nz.co.lindesay.common.webobjects.LEWOApplication.dispatchRequest
(LEWOApplication.java:537)
at nz.co.chong.cbw.webobjects.Application.dispatchRequest
(Application.java:82)
at com.webobjects.appserver._private.WOWorkerThread.runOnce
(WOWorkerThread.java:173)
at com.webobjects.appserver._private.WOWorkerThread.run
(WOWorkerThread.java:254)
at java.lang.Thread.run(Thread.java:552)
</ns1:stackTrace>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Finally, if I look at the
"com.webobjects.webservices.support.xml.WOGlobalIDDeserializer"
class, it has a "byte[] data" instance variable so I can assume that
at least some attempt has been made to deserialise temporary GID's.
=====================
My failed attempt to serialise/deserialise temporary GID's in
WebServices. This may be a good starting point for anybody else
wanting to do this stuff and may also provide a good starting
point for anybody wanting to write a custom serialiser/deserialiser.
Could you tell more about what did fail exactly? Because checking
WOGlobalIDSerializer and WOGlobalIDDeserializer in WebObjects 5.3.2
reveals that these classes are supposed to be able to handle
EOTemporaryGlobalID as well: the data should be serialized in raw
bytes array. EOTemporaryGlobalID instances aren't catched by the
serialization / deserialization process? An exception is thrown?
___
Andrew Lindesay
www.lindesay.co.nz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden