Issue with working on a webservice that has  xml elements with attributes - Service Architecture Leveraging Tuxedo (SALT)

This is  a branchout of Thread: Some more complex sample of invokin WS needed_
We are working on a project that involves a outbound SALT Web service call that includes complex elements with attributes..We are looking for options of how to use FML API's to pass these attribute values from the application code.
We opened a ticket with oracle where we were suggested to frame the entire xml and pass the xml using the FML32 of the complex element. But when we framed the xml for Service and put the entire XML which includes the attributes using the FML ID of Service.
Please find a sample Schema and XML similar to the one we are working on...its associated code
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="" elementFormDefault="qualified" attributeFormDefault="unqualified">
     <xs:element name="Service" type="Service_Type" nillable="true">
               <xs:documentation>Comment describing your root element</xs:documentation>
     <xs:complexType name="Service_Type">
               <xs:element name="DateTime" type="xs:dateTime" nillable="true">
               <xs:element name="UUID" nillable="true">
               <xs:element name="Status" type="xs:string" nillable="true" minOccurs="0" maxOccurs="unbounded">
          <xs:attribute name="Version" type="xs:string" use="required">
          <xs:attribute name="Name" type="xs:string" use="required">
The sample XML is :
___<?xml version="1.0" encoding="UTF-8"?>___
___<!--Sample XML file generated by XMLSpy v2010 rel. 2 (>___
___<Service Name="TestService" Version="1.1" xsi:noNamespaceSchemaLocation="Untitled6.xsd" xmlns:xsi="">___
___     <DateTime>2001-12-17T09:30:47Z</DateTime>___
___     <UUID>text</UUID>___
wsdlcvt generated the mif file with Service as a FML32 type and all its child elements as "mbstring". We tried to leave as it is and we also tried to replace all the child elements and just had a mif entry for "Service" as a mbstring neither produced a different output...Tried to dump using Ferror32 which did not dump any..._
The sample C/C++ code as per suggestions were to do the following...
_1) Have a string with the entire XML for Service_
xmldata="<Service Name=\"TestService"\ Version="1.1\"_ xsi:noNamespaceSchemaLocation=\"Untitled6.xsd\" xmlns:xsi=\"\">_
_     <DateTime>2001-12-17T09:30:47Z</DateTime>_
_     <UUID>text</UUID>_
_2) Use Fmbpack32 to create a mbstring data_
_memcpy(reqmbptr, (char*),xmldata.length());_
_Fmbpack32(mbcodeName,reqmbptr,len, packdata,(FLDLEN32 *)&packedlen,0);_
userlog("Size of packedlen is %d",packedlen);
3) Add the packed data to the output buffer
Fadd32(fmlbuffer,Service, packdata,packedlen );
But we do not see the Service tag populated in the GWWS outbound request.Everything else makes it....any help on how to move ahead would be appreciated... 

It seems you switch to the 10gR3 GA and now the whole XML data is mapped to FLD_MBSTRING.
I will forward my sample to you by mail, but this sample is not offical sample, it is just QA test case. You can refere it and check what's the difference.
Please let me know your mail address.
Xu he 

Thanks Xu. We have been stuck on this for quite a while. The sample code would be great.We are using 10g R3 GA. So shouldn't have any Problem.
Thanks again Xu.


DOM parser and namespaces

Hello -
I have an interesting situation...
I have a webservice and I want my client to be able to send a org.w3c.dom.Document object as the body of the SOAP request.
This is easily done w/ the SAAJ API for web services.
I also want to validate the Document before I send it over the wire.
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(xmlFileToUpload);
I have verified that WebLogic 8.1 is using the Apache Xerces parser.
The XML file that the client will be uploading looks something like this:
<uploadJobData xmlns="" xmlns:xsi="" xsi:noNamespaceSchemaLocation="file://C:\ComputingJobsUpload.xsd">
          <job> .... </job>
My schema looks like this:
<xs:schema xmlns:xs="" elementFormDefault="qualified">
     <xs:element name="uploadJobData">
                    <xs:element name="computingJobs" type="ArrayOfComputingJobs"/>
<xs:element name="name" type="xs:string"/>
     <xs:complexType name="ArrayOfComputingJobs">
               <xs:element name="job" type="ComputingJob" maxOccurs="unbounded"/>
<xs:complexType name="ComputingJob">
               <xs:element name="queuedTime" type="xs:dateTime"/>
               <xs:element name="beginTime" type="xs:dateTime"/>
               <xs:element name="endTime" type="xs:dateTime"/>
               <xs:element name="numCpusUsed" type="xs:short"/>
               <xs:element name="numNodesUsed" type="xs:short"/>
               <xs:element name="chargeFactor" type="xs:decimal"/>
The problem is, when the code turns on validation, I get an error that states:
org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'uploadJobData'.
Why is this?
Also - and an even bigger issue -
When I turn off validation, everything works fine. I can handle this, except that the newly added Document in my SOAPBody now has an XML namespace attribute (xmlns) for every element! My namespace is fairly large, so its making the content length of my SOAP request almost twice as big!
After parsing the XML file in the DocumentBuilder, the XML looks something like this:
<ns1:uploadJobData xmlns="" xmlns:xsi="" xsi:noNamespaceSchemaLocation="file://C:\ComputingJobsUpload.xsd" xmlns:ns1="">     
<computingJobs xmlns="">
<job xmlns="">...</job>
<name xmlns="">JLab</name>
As you can see, the parser places the namespace attribute for every element.
Is there any way to turn this off?
Thanx in advance.

Cannot Parse Simple Document

I can't get a simple document to parse.
XML Document:
<?xml version="1.0" encoding="utf-8" ?>
<rss xmlns="">
<title>MSN Video Highlights</title>
XML Schema:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace=""
     <xs:element name="rss">
                    <xs:element name="channel" type="rs:channel" minOccurs="1" maxOccurs="1"/>
<xs:attribute name="version" type="xs:string" use="optional"/>
     <xs:complexType name="channel">
               <xs:element name="title" type="xs:string" minOccurs="1" maxOccurs="1"/>
               <xs:element name="item" type="rs:item" minOccurs="0" maxOccurs="unbounded"/>
     <xs:complexType name="item">
               <xs:element name="title" type="xs:string" minOccurs="1" maxOccurs="1"/>
Why doesn't the document parse? That is to say, it loads into memory without throwing an exception, but whenever I try to get any elements out, I get null pointers. Calling 'toString()' on the root element shows that XMLBeans wrapped everything in "xml-fragment," which I take to mean it doesn't think the document fits the schema. Yet, I can't see what's wrong. Am I crazy? Thanks. 
A little more research got me in the direction of namespaces. It seems the XMLBeans parser thinks the 'channel' element is in the default, or empty, namespace. When I insert 'xmlns=""' as an attribute to the channel element, the document parses correctly.
I have no idea why the compiler thinks 'channel' is in another namespace. If anyone else does, please let me know. 
For those running into the same problem:
I needed to insert
in the schema root element. I thought 'qualified' was the default, but it turns out 'unqualified' is the default.

Deadlock in schema validation using XMLBeans

I am using WLI8.1 SP2 XMLBeans. I have a schema which has a kind of an infinite
loop. ie I have a complexType element A which has a complexType child element
B which inturn has a complexType child element of type A with minoccurs="0".
When I try to validate the incoming XML using XMLBeans generated from the above
schema, the thread goes into a deadlock and the transaction rollbacks after the
given timeout period.
I checked the workshop_debug.log and found the thread gets struck when it calls
the validate() function of the XMLObject.
Has anybody faced this error or is it a bug in BEA XMLBeans validate function
to handle such schema. I tried to validate the same XML using XML SPY and it worked.
Here is the sample of my schema.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="" elementFormDefault="qualified"
     <xs:element name="ShippingOrderNotification">
                    <xs:element name="ShippingContainer" type="ShippingContainerType" minOccurs="0"
     <xs:complexType name="ShippingContainerType">
               <xs:element name="SubContainer" minOccurs="0" maxOccurs="unbounded">
                              <xs:element name="ShippingContainer" type="ShippingContainerType" minOccurs="0"

How to deal with optional elements?

I'm using clientgen to generate the client classes required for me to access a web service from an EJB. The web services is document-oriented and thus I just assemble the message by building up ordinary Java objects (which were generated by clientgen).
SIDStructure s = new SIDStructure();
                    s.setSIDUniqueReference(createUniqueRef(findCriteriaTO));     s.setSIDOtherCriteria(createSIDOther(findCriteriaTO));
where createUniqueRef and createSIDOther create the necessary objects to assign to the setters on the SIDStructure object.
If I comment out the s.setSIDUniqueReference(..) line above, the XML sent over the wire is as follows:
..<SIDUniqueReference xsi:nil="true"/>
But this doesn't conform to my schema. The schema says:
<xs:complexType name="SIDSearchCriteriaStructure">
......<xs:element ref="SIDUniqueReference"/>
......<xs:element ref="SIDOtherCriteria"/>
So my question is, how can I get WebLogic to not output an element for a field in the client classes that isn't set? i.e. I don't want it to send the element <SIDUniqueReference xsi:nil="true"/> over the wire.
Message was edited by:
I don't know how to make WL omit that tag, but it added --> xsi:nil="true" which is the equivalant of leaving off the tag. The web service that you are calling should treat this as if the tag was not sent (ie: null). 
Unfortunately I'm trying to validate the SOAP body against my schema, which dictates that it can be either one of those elements, but not both.
After speaking to BEA support it appears as though there is a partial solution to this issue. If you add the attributes minOccurs="0" nillable="true" to the elements then the SOAP message is correct. i.e.
<xs:complexType name="SIDSearchCriteriaStructure">
<xs:element ref="SIDUniqueReference" minOccurs="0" nillable="true"/>
<xs:element ref="SIDOtherCriteria" minOccurs="0" nillable="true"/>
I say that this is only a partial fix because elements cannot have minOccurs and nillable attribtes when they are references (as opposed to named elements - e.g. <xs:element name="SIDDNA" type="RestrictedStringType"/>). This is according to XMLSpy anyway. Don't know whether it's W3C legal though.

Insert content in appropriate place

Suppose I have the following schema:
<xs:complexType name="Case">
<xs:element name="Id" type="xs:integer"/>
<xs:element name="Field1" type="xs:string" minOccurs="0"/>
<xs:element name="Field2" type="xs:string" minOccurs="0"/>
<xs:element name="Field3" type="xs:string" minOccurs="0"/>
<xs:element name="Field4" type="xs:string" minOccurs="0"/>
<xs:element name="Field5" type="xs:string" minOccurs="0"/>
<xs:element name="Field6" type="xs:string" minOccurs="0"/>
<xs:element name="Field7" type="xs:string" minOccurs="0"/>
I have the following document:
I need to be able to insert an element in a location where it would be valid with the schema. For example,
Would need to be inserted between Field1 and Field7. Since any of those fields are optional, I can't assume what fields will be there, only that it needs to be inserted in the appropriate position. I had thought of doing an iterative XPath checks to see if, in this case:
Field2 Exists, insert after
Field1 Exists, insert after,
Except this is fragile to changes in the schema... 
I can't think of any better way then what you have thought. 
Thanks, I was afraid of that. Contemplating an XSLT transform that will use the schema to transform the document into a valid one... 
Bryce Fischer wrote:
Thanks, I was afraid of that. Contemplating an XSLT transform that will use the schema to transform the document into a valid one...Hmm!! It can be a good idea. I had another idea of using XMLBeans but it will be very tedious.
In the morning, I tried doing transformation using XSLT searching on google.
Suppose your xsd Case.xsd is:-
<xs:schema xmlns:xs="">
<xs:element name="Case">
<xs:element name="field1" type="xs:string"/>
<xs:element name="field2" type="xs:string"/>
<xs:element name="field3" type="xs:string"/>
<xs:element name="field4" type="xs:string"/>
<xs:element name="field5" type="xs:string"/>
<xs:element name="field6" type="xs:string"/>
You can use following XSLT to insert field3 at the required position:-
<xsl:variable name="elements-after" as="element()*">
<xsl:variable name="root-decl" select="document('Case.xsd')/*/xs:element[#name eq 'Case']"/>
<xsl:variable name="child-decls" select="$root-decl/xs:complexType/xs:sequence/xs:element"/>
<xsl:variable name="decls-after" select="$child-decls[preceding-sibling::xs:element[#name eq 'field3']]"/>
<xsl:sequence select="*[local-name() = $decls-after/#name]"/>
or alternatively you can use
<xsl:stylesheet version="2.0" xmlns:xsl="">
<xsl:template match="/Case">
<xsl:variable name="elements-before" select="field1|fied2"/>
<xsl:copy-of select="* except $elements-before"/>
<field3>PALAK MATHUR</field3>
<xsl:copy-of select="$elements-before"/>
P.S.:- I am having problem with putting xml formatted strings here. It just eats the things and presents something different. If anyone knows how to put the XMLs here, then it would be of great help.
Edited by: palakmathur on Feb 7, 2011 1:33 AM 
Perfect! Thanks. Getting there... Now, just need to figure out how to reference the Schema in the XSLT Resource (hopefully, without hardcoding the entire server URL...) 
Hope this is useful:- 
Thanks. How to path to the schema itself is still eluding me. Its actually part of a WSDL, so I'm pathing it like this currently:
While this works great, I was hoping there would be a better way of including the source document rather than the absolute URL. In OSB, console, under Resource Browser, it says the WSDL Name is "TheSchema", and the Path is "CCS/WSDL". Tried various combinations of
with the "?wsdl" at the end, etc... No such luck yet... 
I am also not able to search for any solution. The issue is that if you hardcode the url then you will have to change it each time you move the code from one domain to another. The solution can be to use Oracle Enterprise Repository to store the common files and referencing it from there. But this is not the clean solution. It is like taking help from another product for a workaround and I hate this. :( 
Thanks for your help, it has been extremely helpful. I decided that the best way would be to use some kind of mapping like this:
<map id="dev">http://devserver</map>
<map id="prod">http://prodserver</map>
Not perfect but it works. I've seen other people mention they use other means (as you mention OER) to handle serving static resources , especially those that can be cached... 
Yes, I have used it many times for setting key-value pairs. I had created an xquery that used to return this mapping properties file. It works perfectly fine. 
Instead of creating a properties file to maintain the values of host/port for environments, you could use a Java callout to fetch the Server and Port details at runtime and use that to access the resources.
For an XSD you can use:
for WSDL you can access it default way like you have mentioned:
You will need to write a simple class to fetch the hostname and port value and call that method as a JavaCallout and use it in your XSLT or XQuery to get the XSD or WSDL resource that you need to access.
This way your service will not be dependent on a property file and will be easier to maintain. Though it adds a Java Callout to overall processing and ultimately it depends on your requirements which way you want to go. I have used both ways (using a properties file and fetching runtime stats using a Java callout) for different scenarios.