How to control the namespace prefix in XML?



I want to create an XML which will be send with a request to a 3rd party site to Create Meeting Attendee.


The documentation is at: http://ift.tt/1qIGMNf


The example given there shows the request XML should be in this format:



<?xml version="1.0"?>
<serv:message xmlns:xsi="http://ift.tt/ra1lAU">
<header>
<securityContext>
<webExID>hostid</webExID>
<password>hostpassword</password>
<siteID>0000</siteID>
<partnerID>9999</partnerID>
<email>johnsmith@xyz.com</email>
</securityContext>
</header>
<body>
<bodyContent xsi:type=
"java:com.webex.service.binding.attendee.CreateMeetingAttendee">
<person>
<name>alterhost</name>
<address>
<addressType>PERSONAL</addressType>
</address>
<email>host1@test.com</email>
<type>MEMBER</type>
</person>
<role>HOST</role>
<sessionKey>808961063</sessionKey>
</bodyContent>
</body>
</serv:message>


Till now I have tried:



XNamespace aw = "http://ift.tt/ra1lAU";
XNamespace xsi = "java:com.tempService";

XElement root = new XElement(aw + "message",
new XAttribute(XNamespace.Xmlns + "serv", aw),
new XElement("header",
new XElement("securityContext", new XElement("siteID", "123"),
new XElement("partnerID", "111"))),

new XElement("body", new XElement("bodyContent",
new XAttribute("xsitype", xsi),
new XElement("person", new XElement("name", "sample content"),
new XElement("email", "xyz@domain.com")),
new XElement("sessionKey", "###"))));


It results the following XML:



<serv:message xmlns:serv="http://ift.tt/ra1lAU">
<header>
<securityContext>
<siteID>123</siteID>
<partnerID>111</partnerID>
</securityContext>
</header>
<body>
<bodyContent xsitype="java:com.tempService">
<person>
<name>sample content</name>
<email>xyz@domain.com</email>
</person>
<sessionKey>###</sessionKey>
</bodyContent>
</body>
</serv:message>


As you can see it does not match with the request XML format.


Problems:



  1. From the top <?xml version="1.0"?> is missing.

  2. <serv:message xmlns:serv=... should be <serv:message xmlns:xsi=...

  3. <bodyContent xsitype="..."> should be <bodyContent xsi:type="...">


I have gone through http://ift.tt/1pbO6ff but could not correct it.


Can any one help me here to resolve this problem. Any help is highly appreciated.


No comments:

Post a Comment