You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Brian Ewins <Br...@btinternet.com> on 2002/12/20 17:06:42 UTC
SchemaVersion is broken was Re: Problems with PROP_SEND_XSI
A bunch of debugging later - I now know first of all that any attempt at
trying to turn off XSI types on the MessageContext will never work:
_call.getMessageContext().setProperty(_call.SEND_TYPE_ATTR,Boolean.FALSE);
...
java.lang.Object _resp = _call.invoke(new java.lang.Object[] {XMLRequest});
because line 2104 of Call.java in the 1.0 release resets the properties
of the MessageContext after you set them. I gave up that tack and I went
back to getting setSchemaVersion() to work.
***It turns out it doesnt work at all.***
Here's code that gets close, again this would go in a WSDL2Java
generated 'createCall':
org.apache.axis.MessageContext msgContext = _call.getMessageContext();
// set soapconstants because of this comment in
// SerializationContextImpl.initialize:
// MAKE SURE soapConstants IS SET CORRECTLY FIRST!
msgContext.setSOAPConstants(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
// we need to explicitly set the encoding style because otherwise
// MessageContext grabs it from the SoapConstants BEFORE
// SoapConstants is set!!
msgContext.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC);
// ok now we can set the schema version
msgContext.setSchemaVersion(org.apache.axis.schema.SchemaVersion.SCHEMA_1999);
// that should have been enough, but all the registered simple types for
// the 1999 schema are WRONG - they are registered in wrong namespace.
QName xmlType=new QName("http://www.w3.org/1999/XMLSchema", "string");
_call.registerTypeMapping(String.class,
new QName("http://www.w3.org/1999/XMLSchema", "string"),
new SimpleSerializerFactory(String.class, xmlType),
new SimpleDeserializerFactory(String.lass, xmlType));
This still produces the wrong message, viz:
<?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>
<ns1:XMLListForms
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="/jetforms/soap/Server.xml">
<XMLRequest xsi:type="xsd:string"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">[data]</XMLRequest>
</ns1:XMLListForms>
</soapenv:Body>
</soapenv:Envelope>
Notice the envelope still uses the 2001 xsi namespace, but switches to
1999 for xsd because of the extra type mapping. This xsi namespace is
being set in SerializationContextImpl.setTypeAttribute to the hardcoded
value Constants.URI_DEFAULT_SCHEMA_XSI when it should probably be be
schemaVersion.getXsiUri(). So, theres no way to fix this without
altering the code in Axis.
Theres a whole heap of bugs here, from encodingStyle being grabbed too
early, to all the the basic 1999 types being registered in the wrong
namespace, to the final disaster of a hardcoded namespace for the type
attribute :( . Interop with 1999 schema services is basically shafted.
I'll have a go at the AxisEngine way of turning off XSI types but this
is getting a bit silly - for services this simple I could have written
the clients by hand (sigh), and I'll probably end up doing that now.
-Baz