You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by chrisneal <ch...@pegs.com> on 2008/06/03 20:15:29 UTC

Re: Is there a way to force namespace prefixes to appear?

Ok, I'm still trying to work through this, and things just get more and more
weird.

I tried a difference approach this time.  Take a known working MessageHeader
element as a String, and build up the the object like this instead:

 MessageHeaderDocument ebDoc = MessageHeaderDocument.Factory.parse(
      "<ns2:MessageHeader
xmlns:ns1=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:ns2=\"http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd\"
ns1:mustUnderstand=\"false\" ns2:version=\"4.0\">      <ns2:From>       
<ns2:PartyId>data</ns2:PartyId>      </ns2:From>      <ns2:To>       
<ns2:PartyId>data</ns2:PartyId>      </ns2:To>     
<ns2:CPAId>data</ns2:CPAId>     
<ns2:ConversationId>data</ns2:ConversationId>      <ns2:Service
ns2:type=\"4.0\">data</ns2:Service>      <ns2:Action>data</ns2:Action>     
<ns2:MessageData>        <ns2:MessageId>30094</ns2:MessageId>       
<ns2:Timestamp>2007-08-14T15:41:21.466-05:00</ns2:Timestamp>     
</ns2:MessageData>    </ns2:MessageHeader>");

So far, so good.  

Then I print out the XML doc with both the xmlText() and toString() methods,
which both match what I created with the parse() method's input.

ebDoc.toString():
<ns2:MessageHeader ns1:mustUnderstand="false" ns2:version="4.0"
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns2="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
  <ns2:From>
    <ns2:PartyId>data</ns2:PartyId>
  </ns2:From>
  <ns2:To>
    <ns2:PartyId>data</ns2:PartyId>
  </ns2:To>
  <ns2:CPAId>data</ns2:CPAId>
  <ns2:ConversationId>data</ns2:ConversationId>
  <ns2:Service ns2:type="4.0">data</ns2:Service>
  <ns2:Action>data</ns2:Action>
  <ns2:MessageData>
    <ns2:MessageId>30094</ns2:MessageId>
    <ns2:Timestamp>2007-08-14T15:41:21.466-05:00</ns2:Timestamp>
  </ns2:MessageData>
</ns2:MessageHeader>

Still so far so good.  But then, somewhere, down in the guts of xmlbeans,
for some reason, the data in the XML document gets changed, and I don't know
why.  I traced the HTTP stream that gets sent to the web service with
Ethereal so I could see what actually get's sent, and *this* MessageHeader
is different?!  Here is what actually gets sent:

		<ns2:MessageHeader
xmlns:ns2="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd"
soapenv:mustUnderstand="0">
			<ns2:From>
				<ns2:PartyId>data</ns2:PartyId>
			</ns2:From>
			<ns2:To>
				<ns2:PartyId>data</ns2:PartyId>
			</ns2:To>
			<ns2:CPAId>data</ns2:CPAId>
			<ns2:ConversationId>data</ns2:ConversationId>
			<ns2:Service ns2:type="4.0">data</ns2:Service>
			<ns2:Action>data</ns2:Action>
			<ns2:MessageData>
				<ns2:MessageId>30094</ns2:MessageId>
				<ns2:Timestamp>2007-08-14T15:41:21.466-05:00</ns2:Timestamp>
			</ns2:MessageData>
		</ns2:MessageHeader>

Notice that the "version" attribute in the MessageHeader is now gone, as is
the ns1 namespace prefix definition.  Apparently those are both critical
components, because the error from the JAXB parser on the web service side
is still:

Unexpected element
http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd}:From
Unexpected element
{http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd}:To
Unexpected element
http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd}:CPAId
Unexpected element
{http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd}:ConversationId
Unexpected element
{http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd}:Service
Unexpected element
{http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd}:Action
Unexpected element
{http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd}:MessageData
Unexpected end of element
{http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd}:MessageHeader

Sorry to beat this one to death with reposts, but it's the last issue I have
before I can say I have a working client.  :S  Any help or thoughts or ideas
would be really appreciated.

Thanks so much,
chris


chrisneal wrote:
> 
> Hello all,
> 
> I've got a XML document build that looks like this:
> 
> 		<MessageHeader
> xmlns="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd"
> soapenv:mustUnderstand="0">
> 			<From>
> 				<PartyId>myparth</PartyId>
> 			</From>
> 			<To>
> 				<PartyId>theirparty</PartyId>
> 			</To>
> 			<CPAId>somethinghere</CPAId>
> 			<ConversationId>blah</ConversationId>
> 			<Service
> xmlns:axis2ns2="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd"
> axis2ns2:type="4.0">data</Service>
> 			<Action>data</Action>
> 			<MessageData>
> 				<MessageId>1</MessageId>
> 				<Timestamp>2008-05-22T15:33:02.576-05:00</Timestamp>
> 			</MessageData>
> 		</MessageHeader>
> 
> which is completely valid.  But for some reason, if I don't make it look
> like this:
> 
>     <ns2:MessageHeader
> xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:ns2="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd"
> ns1:mustUnderstand="false" ns2:version="4.0">
>       <ns2:From>
>         <ns2:PartyId>data</ns2:PartyId>
>       </ns2:From>
>       <ns2:To>
>         <ns2:PartyId>data</ns2:PartyId>
>       </ns2:To>
>       <ns2:CPAId>data</ns2:CPAId>
>       <ns2:ConversationId>data</ns2:ConversationId>
>       <ns2:Service ns2:type="4.0">data</ns2:Service>
>       <ns2:Action>data</ns2:Action>
>       <ns2:MessageData>
>         <ns2:MessageId>30094</ns2:MessageId>
>         <ns2:Timestamp>2007-08-14T15:41:21.466-05:00</ns2:Timestamp>
>       </ns2:MessageData>
>     </ns2:MessageHeader>
> 
> Then the service errors out with a bunch of "Unexpected element" messages.
> :S
> 
> Is there a way in xmlbeans to have it redundantly display the namespace
> prefix?
> 
> Thanks!
> 
> 

-- 
View this message in context: http://www.nabble.com/Is-there-a-way-to-force-namespace-prefixes-to-appear--tp17426936p17629651.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org