Hi,
I am a new user of Axis. I have written a simple program but I have
encountered a namespace program. I found from the output of SOAPMessage.writeTo
() that the prefixes and URIs of the attributes are missing if they are added
using SOAPElement.addAttribute(Name, String) where the prefix and URI are
specified thru the Name object. I have tried for a long time but I still can't
get it work. Can anyone help me? Following is my program:
public class Tester {
public static void main(String[] args) {
try
{
SOAPFactory sf = SOAPFactory.newInstance();
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage();
SOAPPart sp = message.getSOAPPart();
SOAPEnvelope se = sp.getEnvelope();
SOAPBody sb = se.getBody();
SOAPHeader sh = se.getHeader();
SOAPBodyElement s = sb.addBodyElement(se.createName
("Manifest","eb","http://www.oasis-open.org/committees/ebxml-msg/schema/msg-
header-2_0.xsd"));
SOAPElement s1 = s.addChildElement("Reference","eb");
s1.addAttribute(se.createName
("href", "xlink", "http://www.w3.org/1999/xlink"),"http://testing");
FileOutputStream fos = new FileOutputStream
("/CECID/tester.xml");
message.writeTo(fos);
fos.close();
}
catch (Throwable e)
{
e.printStackTrace();
}
}
}
The output:
<?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>
<eb:Manifest xmlns:eb="http://www.oasis-open.org/committees/ebxml-
msg/schema/msg-header-2_0.xsd">
<eb:Reference href="http://testing" xmlns:eb="http://www.oasis-
open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd"/>
</eb:Manifest>
</soapenv:Body>
</soapenv:Envelope>
I suppose there should be a prefix "xlink" before "href" and a namespace
declaration of "xlink" in the "reference" tag. However, I can never get that
output. Can anyone tell me why? Thanks in advance.
Best Regards,
Hugo
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/