[
http://issues.apache.org/jira/browse/TUSCANY-505?page=comments#action_12418408
]
Simon Laws commented on TUSCANY-505:
------------------------------------
1/ Apologies about the spaces in the namespaces in XSD/XML. I have no idea how
they got there. I have just checked the source files from which I copied these
examples and they do not have spaces. So the spaces appeared in the process of
me cutting them out of the example files and pasting them into the JIRA. I know
not how but sorry about that. I must be going senile:-(
2/ Let me approach the actual problem in a slightly different way. The
XSD/XML/code I gave is actually a contrived example. The problem also occurs in
trying to get C++ and Java SCA to interoperate. C++ SCA produces XML with
xsi:type entries on the root element. The SDO data binding in Java SCA fails in
the way described and hence C++ and Java SCA are not currently interoperable
which is a shame. The code that converts the input XML stream to the SDO data
object can be found in
org.apache.tuscany.databinding.sdo.SDOXMLHelper.java::toDataObject() and does
this...
XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
XMLDocument document = xmlHelper.load(new
ByteArrayInputStream(xmlBytes));
return document.getRootObject();
In the case of a message arriving over SOAP there is no schema in the XML of
course but I would expect the type model in SDO to have been created based on
the schema in the WSDL. From your testing it seems to work if you have loaded
the correct schema beforehand so maybe this means that there is a problem with
the typeHelper in the SDO binding code. I'm just guessing here as I don;t know
what SDOUtil.createXMLHelper(typeHelper); does. I haven't managed to track back
through the call stack yet to find out how this works but if anyone knows of
the top of their head feel free to shout.
For extra information here are the working and non working SOAP messages...
First the message from C++ that doesn't work for the reasons discussed....
POST /interop-stockquote/services/StockQuoteService HTTP/1.1
User-Agent: Axis2/C
SOAPAction: "http://www.quickstockquote.com/StockQuoteService/getQuote"
Content-Length: 713
Content-Type: text/xml;charset=UTF-8
Host: localhost:8080
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:To>http://localhost:8081/interop-stockquote/services/StockQuoteService</wsa:To>
<wsa:Action>http://www.quickstockquote.com/StockQuoteService/getQuote</wsa:Action>
<wsa:MessageID>870bf065-6849-47fb-86ad-224b81513541</wsa:MessageID>
</soapenv:Header>
<soapenv:Body>
<getQuote xsi:type="getQuote"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.quickstockquote.com/StockQuoteService/"
xmlns:tns="http://www.quickstockquote.com/StockQuoteService/">
<symbol>IBM</symbol>
</getQuote>
</soapenv:Body>
</soapenv:Envelope>
Here is the same message but from a Java cleint. This does work....
POST /interop-stockquote/services/StockQuoteService HTTP/1.1
User-Agent: Axis/2.0
SOAPAction: http://www.quickstockquote.com/StockQuoteService/getQuote
Host: localhost:8080
Content-Length: 307
Content-Type: text/xml; charset=UTF-8
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header />
<soapenv:Body>
<Service:getQuote
xmlns:Service="http://www.quickstockquote.com/StockQuoteService/">
<symbol>IBM</symbol>
</Service:getQuote>
</soapenv:Body>
</soapenv:Envelope>
> xsi:type on root element fo XML doc causes problems
> ---------------------------------------------------
>
> Key: TUSCANY-505
> URL: http://issues.apache.org/jira/browse/TUSCANY-505
> Project: Tuscany
> Type: Bug
> Components: Java SDO Implementation
> Versions: Java-M1
> Environment: Windows XP
> Reporter: Simon Laws
>
> If I read the following doc:
> <tns:RootElement xmlns:p="commonj.sdo"
> xmlns:tns="http://www.apache.org/tuscany/interop"
> xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.apache.org/tuscany/interop interop01.xsd">
> <SimpleTypeWithName>SimpleTypeWithName</SimpleTypeWithName>
> </tns:RootElement>
> With the following schema
> <schema xmlns=" http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.apache.org/tuscany/interop"
> xmlns:tns=" http://www.apache.org/tuscany/interop">
>
> <include schemaLocation="interop10.xsd"/>
>
> <!-- top level test type -->
> <complexType name="ComplexTypeRootType">
> <sequence>
> <!-- simple types -->
> <element name="SimpleTypeWithName" type="tns:SimpleTypeWithNameType"/>
> </sequence>
> </complexType>
>
> <element name="RootElement" type="tns:ComplexTypeRootType"/>
> </schema>
> The I get a valid document (doc) with some data objects in it out of the
> following code:
> FileInputStream inFileStream = new FileInputStream (inFileName);
> XMLDocument doc = XMLHelper.INSTANCE.load(inFileStream);
> If I try in read in (note I have added and xsi:type attribute):
> <tns:RootElement xmlns:p="commonj.sdo"
> xsi:type="tns:ComplexTypeRootType"
> xmlns:tns="http://www.apache.org/tuscany/interop "
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.apache.org/tuscany/interop interop01.xsd">
> <SimpleTypeWithName>SimpleTypeWithName</SimpleTypeWithName>
> </tns:RootElement>
> The XMLHelper silently makes an empty document, i.e. the root element is null.
> I talked with Frank and he suggested changing the xsi:type to refer to a type
> that extends the root element type. This produced the same effect, i.e. and
> empty document. However xsi:type does seem to behave in both the base type
> and extension type case when attached to elements other than the root
> element.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]