SaajUtils { public static QName toQName(Name name) { if (StringUtils.hasLength(name.getURI()) && StringUtils.hasLength(name.getPrefix())) { return new QName(name.getURI(), name.getLocalName(), name.getPrefix()); } else if (StringUtils.hasLength(name.getURI())) { return new QName(name.getURI(), name.getLocalName()); } else { return new QName(name.getLocalName()); } }  static int getSaajVersion(); static int getSaajVersion(SOAPMessage soapMessage); static int getSaajVersion(SOAPElement soapElement); static String getSaajVersionString(); static Name toName(QName qName, SOAPElement resolveElement); static QName toQName(Name name); static SOAPMessage loadMessage(Resource resource, MessageFactory messageFactory); static SOAPEnvelope getEnvelope(SOAPElement element); static SOAPElement getFirstBodyElement(SOAPBody body); static final int SAAJ_11; static final int SAAJ_12; static final int SAAJ_13; }
@Test public void testToQName() throws Exception { SOAPMessage message = messageFactory.createMessage(); Name name = message.getSOAPPart().getEnvelope().createName("localPart", null, null); QName qName = SaajUtils.toQName(name); Assert.assertNotNull("Invalid qName", qName); Assert.assertEquals("Invalid namespace", name.getURI(), qName.getNamespaceURI()); Assert.assertFalse("Invalid prefix", StringUtils.hasLength(qName.getPrefix())); Assert.assertFalse("Invalid namespace", StringUtils.hasLength(qName.getNamespaceURI())); }