List of usage examples for javax.xml.namespace QName QName
public QName(final String namespaceURI, final String localPart)
QName
constructor specifying the Namespace URI and local part.
If the Namespace URI is null
, it is set to javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI .
From source file:net.bpelunit.test.util.TestUtil.java
public static SOAPOperationCallIdentifier getCall(String path, String wsdl, String operationName, SOAPOperationDirectionIdentifier direction) throws SpecificationException { String abspath = FileUtils.toFile(TestUtil.class.getResource(path)).getAbsolutePath() + File.separator; Definition d = SpecificationLoader.loadWsdlDefinition(abspath, wsdl, "TEST"); Partner p = new Partner("MyPartner", d, null, ""); QName service = new QName("http://www.example.org/MyPartner/", "MyPartner"); SOAPOperationCallIdentifier operation = p.getOperation(service, "MyPartnerSOAP", operationName, direction); return operation; }
From source file:com.nortal.jroad.wsdl.XTeeSoapProvider.java
private List<SOAPHeader> makeHeaders(Definition definition) throws WSDLException { List<SOAPHeader> list = new ArrayList<SOAPHeader>(); String[] parts = new String[] { XTeeHeader.CLIENT.getLocalPart(), XTeeHeader.SERVICE.getLocalPart(), XTeeHeader.USER_ID.getLocalPart(), XTeeHeader.ID.getLocalPart(), XTeeHeader.PROTOCOL_VERSION.getLocalPart() }; ExtensionRegistry extReg = definition.getExtensionRegistry(); for (int i = 0; i < parts.length; i++) { SOAPHeader header = (SOAPHeader) extReg.createExtension(BindingInput.class, new QName(SOAP_11_NAMESPACE_URI, "header")); header.setMessage(new QName(definition.getTargetNamespace(), XTeeWsdlDefinition.XROAD_HEADER)); header.setPart(parts[i]);/*from ww w .j a v a 2 s . co m*/ if (use.equalsIgnoreCase(LITERAL)) { header.setUse(LITERAL); } else { header.setUse(ENCODED); header.setEncodingStyles(Arrays.asList(ENCODING)); } header.setNamespaceURI(XTeeWsdlDefinition.XROAD_NAMESPACE); list.add(header); } return list; }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.filtering.AttributeFilterPolicyGroupBeanDefinitionParser.java
/** {@inheritDoc} */ public BeanDefinition parse(Element config, ParserContext context) { String policyId = DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "id")); log.debug("Parsing attribute filter policy group {}", policyId); List<Element> children; Map<QName, List<Element>> childrenMap = XMLHelper.getChildElements(config); children = childrenMap.get(new QName(AttributeFilterNamespaceHandler.NAMESPACE, "PolicyRequirementRule")); SpringConfigurationUtils.parseInnerCustomElements(children, context); children = childrenMap.get(new QName(AttributeFilterNamespaceHandler.NAMESPACE, "AttributeRule")); SpringConfigurationUtils.parseInnerCustomElements(children, context); children = childrenMap.get(new QName(AttributeFilterNamespaceHandler.NAMESPACE, "PermitValueRule")); SpringConfigurationUtils.parseInnerCustomElements(children, context); children = childrenMap.get(new QName(AttributeFilterNamespaceHandler.NAMESPACE, "AttributeFilterPolicy")); SpringConfigurationUtils.parseInnerCustomElements(children, context); return null;/*from ww w .j a v a2s .c o m*/ }
From source file:org.javelin.sws.ext.bind.SweJaxbContextFactoryTest.java
@Test public void scanExceptionClassForJaxbRi() throws Exception { JAXBContext ctx = JAXBContext.newInstance(IllegalArgumentException.class); System.out.println(ctx.toString()); ctx.createMarshaller().marshal(new JAXBElement<IllegalArgumentException>(new QName("urn:test", "e"), IllegalArgumentException.class, new IllegalArgumentException("exception")), System.out); }
From source file:org.apache.servicemix.camel.nmr.CxfMessageTest.java
public void testInvokingServiceFromCXFClient() throws Exception { URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl"); System.out.println(wsdlURL);/*from w w w . j a v a 2 s .c o m*/ PersonService ss = new PersonService(wsdlURL, new QName("http://servicemix.apache.org/samples/wsdl-first", "PersonService")); Person client = ss.getSoap(); ClientProxy.getClient(client).getOutInterceptors().add(new LoggingOutInterceptor()); ClientProxy.getClient(client).getInInterceptors().add(new LoggingInInterceptor()); Holder<String> personId = new Holder<String>(); personId.value = "world"; Holder<String> ssn = new Holder<String>(); Holder<String> name = new Holder<String>(); client.getPerson(personId, ssn, name); assertEquals("we should get the right answer from router", "Bonjour", name.value); }
From source file:com.tangfan.test.UserServiceTest.java
/** * add jaxws-ri???/*from ww w.j a v a 2 s . co m*/ */ @Test public void add() { try { //1.?xml JAXBContext jaxb = JAXBContext.newInstance(LicenseInfo.class); User lu = new User(); lu.setId(0); lu.setNickname(""); lu.setUsername("admin"); lu.setPassword("123"); LicenseInfo info = new LicenseInfo(); info.setLoginUser(lu); QName qName = new QName(ns, "licenseInfo"); JAXBElement<LicenseInfo> jele = new JAXBElement<LicenseInfo>(qName, LicenseInfo.class, info); Marshaller mars = jaxb.createMarshaller(); mars.setProperty(Marshaller.JAXB_FRAGMENT, true);//xml mars.setProperty(Marshaller.JAXB_ENCODING, "utf-8");//? //2.?dom Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); mars.marshal(jele, doc); //3.Headers.create?header WSBindingProvider wsb = (WSBindingProvider) port; wsb.setOutboundHeaders(Headers.create(doc.getDocumentElement())); User u = new User(); u.setId(2); u.setUsername("master"); u.setNickname("jboss?"); u.setPassword("123456"); port.add(u); } catch (UserException_Exception e) { System.out.println(e.getMessage()); } catch (JAXBException e) { e.printStackTrace(); } catch (ParserConfigurationException e) { e.printStackTrace(); } }
From source file:org.jboss.as.test.integration.ws.authentication.EJBEndpointSecuredWSDLAccessTestCase.java
@Test public void createService() throws Exception { QName serviceName = new QName("http://jbossws.org/authenticationForWSDL", "EJB3ServiceForWSDL"); URL wsdlURL = new URL(baseUrl, "/jaxws-authentication-ejb3-for-wsdl/EJB3ServiceForWSDL?wsdl"); try {//from w w w.j ava2 s .c o m Service service = Service.create(wsdlURL, serviceName); EJBEndpointIface proxy = service.getPort(EJBEndpointIface.class); Assert.fail("Proxy shouldn't be created because WSDL access should be secured"); } catch (WebServiceException e) { // failure is expected } }
From source file:org.cleverbus.common.Tools.java
/** * Marshals object graph into XML.//w w w . j a va 2 s . c o m * * @param obj the object graph * @param qName the QName * @return XML as string * @see Marshaller */ @SuppressWarnings("unchecked") public static <T> String marshalToXml(T obj, QName qName) { StringWriter stringWriter = new StringWriter(); try { Marshaller marshaller = JAXBContext.newInstance(obj.getClass()).createMarshaller(); Object element; if (qName != null) { element = new JAXBElement<T>(qName, (Class<T>) obj.getClass(), obj); } else { qName = new QName(obj.getClass().getPackage().getName(), obj.getClass().getSimpleName()); element = new JAXBElement<T>(qName, (Class<T>) obj.getClass(), obj); } marshaller.marshal(element, stringWriter); return stringWriter.toString(); } catch (JAXBException e) { throw new RuntimeException(e); } }
From source file:test.integ.be.fedict.hsm.ws.WSS4JTest.java
@Test public void testSecurity() throws Exception { QName serviceName = new QName("http://www.example.com/test", "TestService"); Service service = Service.create(serviceName); QName portName = new QName("http://www.example.com/test", "TestPort"); String endpointAddress = this.baseURL + "test"; LOG.debug("endpoint address: " + endpointAddress); service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress); Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE); BindingProvider bindingProvider = (BindingProvider) dispatch; SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding(); List handlerChain = soapBinding.getHandlerChain(); handlerChain.add(new WSS4JTestSOAPHandler()); soapBinding.setHandlerChain(handlerChain); MessageFactory messageFactory = soapBinding.getMessageFactory(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPBody soapBody = soapMessage.getSOAPBody(); QName payloadName = new QName("http://www.example.com/test", "Payload", "prefix"); SOAPBodyElement soapBodyElement = soapBody.addBodyElement(payloadName); soapBodyElement.addTextNode("hello world"); SOAPMessage replyMessage = dispatch.invoke(soapMessage); }
From source file:com.counter.IntegrationTest.java
public void testAdd() throws Exception { Bus bus = new SpringBusFactory().createBus("client.xml"); BusFactory.setDefaultBus(bus);/* w w w . j ava 2 s.c o m*/ CounterFactoryService counters = new CounterFactoryService( new URL("http://localhost:55555/counterFactory?wsdl")); CounterFactoryPortType factory = counters.getCounterFactoryPortTypePort(); W3CEndpointReference epr = factory.createCounter(); CounterService service = new CounterService(); CounterPortType counter = service.getPort(epr, CounterPortType.class); assertEquals(counter.add(10), 10); assertEquals(counter.add(10), 20); assertEquals(counter.add(10), 30); assertEquals(((JAXBElement) counter.getResourceProperty(new QName("http://counter.com", "Value")).getAny() .get(0)).getValue(), 30); counter.setTerminationTime(Calendar.getInstance(), new Holder<Calendar>(), new Holder<Calendar>()); }