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:gov.nih.nci.caxchange.transcend.CaXchangeRequestService.java
private String getCaXchangeRequestxml(final Message parameter) { String requestXML = null;/* w ww .j av a 2s.c o m*/ final QName qname = new QName("http://caXchange.nci.nih.gov/caxchangerequest", "caxchangerequest"); final JAXBElement<Message> message = new JAXBElement<Message>(qname, Message.class, parameter); final StringWriter sw = new StringWriter(); try { getMarshaller().marshal(message, sw); requestXML = sw.toString(); } catch (JAXBException e) { LOG.error("Error marshalling CaXchangeRequest!", e); } return requestXML; }
From source file:org.apache.servicemix.http.ConsumerEndpointTest.java
public void testHttpInOutWithTimeout() throws Exception { HttpComponent http = new HttpComponent(); HttpConsumerEndpoint ep = new HttpConsumerEndpoint(); ep.setService(new QName("urn:test", "svc")); ep.setEndpoint("ep"); ep.setTargetService(new QName("urn:test", "echo")); ep.setLocationURI("http://localhost:8192/ep1/"); ep.setDefaultMep(MessageExchangeSupport.IN_OUT); ep.setTimeout(1000);/*from ww w.ja v a 2 s.co m*/ http.setEndpoints(new HttpEndpointType[] { ep }); container.activateComponent(http, "http"); EchoComponent echo = new EchoComponent() { public void onMessageExchange(MessageExchange exchange) { super.onMessageExchange(exchange); } protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException { try { Thread.sleep(1500); } catch (InterruptedException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } return super.transform(exchange, in, out); } }; echo.setService(new QName("urn:test", "echo")); echo.setEndpoint("endpoint"); container.activateComponent(echo, "echo"); container.start(); PostMethod post = new PostMethod("http://localhost:8192/ep1/"); post.setRequestEntity(new StringRequestEntity("<hello>world</hello>")); new HttpClient().executeMethod(post); String res = post.getResponseBodyAsString(); log.info(res); if (post.getStatusCode() != 500) { throw new InvalidStatusResponseException(post.getStatusCode()); } Thread.sleep(1000); }
From source file:com.eviware.soapui.impl.wsdl.support.soap.SoapRequestBuilder.java
private void createElementForPart(Part part, XmlCursor cursor, SampleXmlUtil xmlGenerator) throws Exception { QName elementName = part.getElementName(); QName typeName = part.getTypeName(); if (elementName != null) { cursor.beginElement(elementName); if (wsdlContext.hasSchemaTypes()) { SchemaGlobalElement elm = wsdlContext.getSchemaTypeLoader().findElement(elementName); if (elm != null) { cursor.toFirstChild();// w w w . jav a 2s .c om xmlGenerator.createSampleForType(elm.getType(), cursor); } else log.error("Could not find element [" + elementName + "] specified in part [" + part.getName() + "]"); } cursor.toParent(); } else { cursor.beginElement(new QName(wsdlContext.getDefinition().getTargetNamespace(), part.getName())); if (typeName != null && wsdlContext.hasSchemaTypes()) { SchemaType type = wsdlContext.getSchemaTypeLoader().findType(typeName); if (type != null) { cursor.toFirstChild(); xmlGenerator.createSampleForType(type, cursor); } else log.error("Could not find type [" + typeName + "] specified in part [" + part.getName() + "]"); } cursor.toParent(); } }
From source file:argendata.api.DatasetAPIService.java
@GET @Path("/by/title/{t}.rdf") @Produces("application/xml") public String getDatasetByTitleRDFXML(@PathParam(value = "t") String title) { try {/*www . jav a 2 s .c o m*/ title = URLDecoder.decode(title, "UTF-8"); validate(title); title = Parsing.withoutSpecialCharacters(title); } catch (Exception e1) { throw new NotFoundException("Recurso no encontrado"); } QName qName = new QName(properties.getNamespace(), "Dataset:" + title); String rdfxml; try { rdfxml = repositoryGateway.getDatasetRDFByQName(qName); } catch (Exception e) { throw new NotFoundException("Recurso no encontrado"); } HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.setContentType(MediaType.APPLICATION_XML); return rdfxml;// new ResponseEntity<String>(rdfxml, responseHeaders, // HttpStatus.CREATED); }
From source file:org.apache.cxf.systest.jaxrs.JAXRSSoapBookTest.java
private void doTestHelloSoapCustomDataBinding(String address) throws Exception { final QName serviceName = new QName("http://hello.com", "HelloWorld"); final QName portName = new QName("http://hello.com", "HelloWorldPort"); Service service = Service.create(serviceName); service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, address); HelloWorld hw = service.getPort(HelloWorld.class); Client cl = ClientProxy.getClient(hw); HTTPConduit http = (HTTPConduit) cl.getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout(0); httpClientPolicy.setReceiveTimeout(0); http.setClient(httpClientPolicy);/* w w w . jav a 2s. c o m*/ User user = new UserImpl("Barry"); User user2 = hw.echoUser(user); assertNotSame(user, user2); assertEquals("Barry", user2.getName()); }
From source file:org.apache.servicemix.http.HttpWsdlTest.java
protected Definition createDefinition(boolean rpc) throws WSDLException { Definition def = WSDLFactory.newInstance().newDefinition(); def.setTargetNamespace("http://porttype.test"); def.addNamespace("tns", "http://porttype.test"); def.addNamespace("xsd", "http://www.w3.org/2000/10/XMLSchema"); def.addNamespace("w", "uri:hello"); Message inMsg = def.createMessage(); inMsg.setQName(new QName("http://porttype.test", "InMessage")); inMsg.setUndefined(false);//from w w w . ja v a2s .co m Part part1 = def.createPart(); part1.setName("part1"); if (rpc) { part1.setTypeName(new QName("http://www.w3.org/2000/10/XMLSchema", "int")); } else { part1.setElementName(new QName("uri:hello", "world")); } inMsg.addPart(part1); Part part2 = def.createPart(); part2.setName("part2"); part2.setElementName(new QName("uri:hello", "world")); inMsg.addPart(part2); def.addMessage(inMsg); Message outMsg = def.createMessage(); outMsg.setQName(new QName("http://porttype.test", "OutMessage")); outMsg.setUndefined(false); Part part3 = def.createPart(); part3.setName("part3"); part3.setElementName(new QName("uri:hello", "world")); outMsg.addPart(part3); def.addMessage(outMsg); PortType type = def.createPortType(); type.setUndefined(false); type.setQName(new QName("http://porttype.test", "MyConsumerInterface")); Operation op = def.createOperation(); op.setName("Hello"); Input in = def.createInput(); in.setMessage(inMsg); op.setInput(in); op.setUndefined(false); Output out = def.createOutput(); out.setMessage(outMsg); op.setOutput(out); type.addOperation(op); def.addPortType(type); ByteArrayOutputStream baos = new ByteArrayOutputStream(); WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, baos); log.info(baos.toString()); return def; }
From source file:com.alfaariss.oa.profile.aselect.ws.ASelectProfileWS.java
/** * Initialize the authentication process. * /* ww w . ja v a 2 s . c o m*/ * @param request The OA authenticate request object model. * @return The authenticationResponse. * @throws AxisFault If processing fails. */ public OMElement authenticate(OMElement request) throws AxisFault { String remoteAddr = null; try { if (!_service.isInitialized()) { _logger.warn("Service not initialized or disabled"); //TODO server busy error (Erwin) throw new OAException(SystemErrors.ERROR_NOT_INITIALIZED); } //Retrieve message context MessageContext context = MessageContext.getCurrentMessageContext(); if (context == null) { _logger.warn("Could not retrieve message context"); throw new OAException(SystemErrors.ERROR_INTERNAL); } //Debug incoming envelope if (_logger.isDebugEnabled()) { SOAPEnvelope envelope = context.getEnvelope(); _logger.debug(envelope); } //Retrieve remote address remoteAddr = (String) context.getProperty(MessageContext.REMOTE_ADDR); //Retrieve parameters String oaID = null; OMElement om = request.getFirstChildWithName( new QName(ASelectProfileWS.TARGET_NAMESPACE, ASelectProcessor.PARAM_ASELECTSERVER)); if (om != null) { oaID = om.getText(); } else { om = request.getFirstChildWithName(new QName(ASelectProfileWS.TARGET_NAMESPACE, ASelectProcessor.PARAM_ASELECTSERVER_ALTERATIVE)); if (om != null) { oaID = om.getText(); } } String requestorID = null; om = request.getFirstChildWithName( new QName(ASelectProfileWS.TARGET_NAMESPACE, ASelectProcessor.PARAM_APPID)); if (om != null) { requestorID = om.getText(); } String requestorURL = null; om = request.getFirstChildWithName( new QName(ASelectProfileWS.TARGET_NAMESPACE, ASelectProcessor.PARAM_APPURL)); if (om != null) { requestorURL = om.getText(); } String remoteOrganization = null; om = request.getFirstChildWithName( new QName(ASelectProfileWS.TARGET_NAMESPACE, ASelectProcessor.PARAM_REMOTE_ORGANIZATION)); if (om != null) { remoteOrganization = om.getText(); } String sForcedLogon = null; // default false om = request.getFirstChildWithName( new QName(ASelectProfileWS.TARGET_NAMESPACE, ASelectProcessor.PARAM_FORCED_LOGON)); if (om != null) { sForcedLogon = om.getText(); } String sPassive = null; // default false om = request.getFirstChildWithName( new QName(ASelectProfileWS.TARGET_NAMESPACE, ASelectProcessor.PARAM_PASSIVE)); if (om != null) { sPassive = om.getText(); } String uid = null; om = request.getFirstChildWithName( new QName(ASelectProfileWS.TARGET_NAMESPACE, ASelectProcessor.PARAM_UID)); if (om != null) { uid = om.getText(); } String country = null; om = request.getFirstChildWithName( new QName(ASelectProfileWS.TARGET_NAMESPACE, ASelectProcessor.PARAM_COUNTRY)); if (om != null) { country = om.getText(); } String language = null; om = request.getFirstChildWithName( new QName(ASelectProfileWS.TARGET_NAMESPACE, ASelectProcessor.PARAM_LANGUAGE)); if (om != null) { language = om.getText(); } //Bussiness processing ISession session = _service.initiateAuthentication(oaID, requestorID, requestorURL, remoteOrganization, sForcedLogon, uid, remoteAddr, country, language, isSigned(context), sPassive); //Create redirect URL StringBuffer sbAsUrl = new StringBuffer(_service.getRedirectURLBase()); sbAsUrl.append("?request=login1&"); sbAsUrl.append(ASelectProcessor.PARAM_ASELECTSERVER); sbAsUrl.append("="); sbAsUrl.append(oaID); sbAsUrl.append("&rid=").append(session.getId()); //Create response OMFactory fac = context.getEnvelope().getOMFactory(); OMNamespace omNs = fac.createOMNamespace(ASelectProfileWS.TARGET_NAMESPACE, "oa"); OMNamespace omNs1 = fac.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi"); OMNamespace omNs2 = fac.createOMNamespace("http://www.w3.org/2001/XMLSchema", "xsd"); OMElement authnResponse = fac.createOMElement(AUTHENTICATE_RESPONSE, omNs); authnResponse.declareNamespace(omNs1); authnResponse.declareNamespace(omNs2); authnResponse.addChild(createParam(fac, ASelectProcessor.PARAM_ASELECT_URL, sbAsUrl.toString(), omNs, "xsd:string", omNs1)); //Debug outgoing envelope if (_logger.isDebugEnabled()) { _logger.debug(authnResponse); } return authnResponse; } catch (BusinessRuleException e) { throw new WSFault(e); } catch (OAException e) { _logger.error("Error while processing authenticate request", e); throw new WSFault(e); } catch (Exception e) { _logger.fatal("Internal error while processing authenticate request", e); throw new WSFault(new OAException(SystemErrors.ERROR_INTERNAL)); } }
From source file:argendata.service.impl.DatasetServiceImpl.java
@Override public Dataset getApprovedDatasetByQName(String qName) { logger.debug("A getDatasetByQName llega:" + qName); QName QN = new QName(properties.getNamespace(), qName); Dataset myDataset;/*from ww w .j a v a 2 s . co m*/ try { myDataset = this.datasetDao.getById(QN); } catch (java.lang.ClassCastException e) { myDataset = null; } return myDataset; }
From source file:com.bradmcevoy.property.BeanPropertySource.java
@Override public List<QName> getAllPropertyNames(Resource r) { BeanPropertyResource anno = getAnnotation(r); if (anno == null) return null; PropertyDescriptor[] pds = PropertyUtils.getPropertyDescriptors(r); List<QName> list = new ArrayList<QName>(); for (PropertyDescriptor pd : pds) { if (pd.getReadMethod() != null) { list.add(new QName(anno.value(), pd.getName())); }// w w w .ja va2 s.c o m } return list; }