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:com.predic8.membrane.core.interceptor.WADLInterceptor.java
@Override protected void rewrite(Exchange exc) throws Exception, IOException { log.debug("Changing endpoint address in WADL"); ByteArrayOutputStream stream = new ByteArrayOutputStream(); Relocator relocator = new Relocator(new OutputStreamWriter(stream, exc.getResponse().getCharset()), getLocationProtocol(), getLocationHost(exc), getLocationPort(exc), pathRewriter); relocator.getRelocatingAttributes().put(new QName(WADL_NS, "resources"), "base"); relocator.getRelocatingAttributes().put(new QName(WADL_NS, "include"), "href"); relocator.relocate(// w ww .j a va 2 s . c o m new InputStreamReader(exc.getResponse().getBodyAsStreamDecoded(), exc.getResponse().getCharset())); exc.getResponse().setBodyContent(stream.toByteArray()); }
From source file:org.javelin.sws.ext.bind.SweJaxbContextFactoryTest.java
@Test public void defaultPackage() throws Exception { JAXBContext ctx = SweJaxbContextFactory.createContext("", null); // but we may marshal objects of built-in classes - XSD simple types ctx.createMarshaller().marshal(/*w w w . j a v a2 s .c om*/ new JAXBElement<String>(new QName("urn:test", "str"), String.class, "content"), System.out); }
From source file:org.apache.servicemix.http.HttpAddressingTest.java
public void testOk() throws Exception { DefaultServiceMixClient client = new DefaultServiceMixClient(jbi); InOut me = client.createInOutExchange(); me.setService(new QName("http://test", "MyProviderService")); InputStream fis = getClass().getResourceAsStream("addressing-request.xml"); me.getInMessage().setContent(new StreamSource(fis)); client.sendSync(me);//from ww w .j a v a 2s .c o m if (me.getStatus() == ExchangeStatus.ERROR) { if (me.getError() != null) { throw me.getError(); } else { fail("Received ERROR status"); } } else if (me.getFault() != null) { String txt = new SourceTransformer().toString(me.getFault().getContent()); client.done(me); fail("Received fault: " + txt); } else { Node node = new SourceTransformer().toDOMNode(me.getOutMessage()); client.done(me); log.info(new SourceTransformer().toString(node)); assertEquals("myid", textValueOfXPath(node, "//*[local-name()='RelatesTo']")); assertNotNull(textValueOfXPath(node, "//*[local-name()='MessageID']")); } }
From source file:com.myrealtor.service.external.AxisRPCClient.java
public void registerProvider(Provider provider) throws AxisFault { log.debug("registerProvider: " + provider); // QName of the target method QName qName = new QName("http://service.apartment.com", "registerProvider"); // Constructing the arguments array for the method invocation Object[] opAddEntryArgs = new Object[] { provider }; // Invoking the method serviceClient.invokeRobust(qName, opAddEntryArgs); serviceClient.cleanup();/* w ww.j a v a 2 s.c o m*/ serviceClient.cleanupTransport(); }
From source file:org.semispace.ws.client.SemiSpaceProxy.java
protected static WsSpace readSpaceServiceAsStandardPort(String endpointAddress) { QName SERVICE_NAME = new QName("http://ws.semispace.org/", "WsSpace"); QName PORT_NAME = new QName("http://ws.semispace.org/", "WsSpacePort"); Service service = Service.create(SERVICE_NAME); // Add a port to the Service service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress); WsSpace hw = service.getPort(WsSpace.class); return hw;/*from w w w . j a v a 2 s.co m*/ }
From source file:io.mapzone.arena.csw.UpdateRecordRequest.java
@Override protected void prepare(IProgressMonitor monitor) throws Exception { writeElement(CSW, "Update", () -> { // record QName name = new QName(Namespaces.CSW, "Record"); writeObject(new JAXBElement(name, RecordXML.class, null, record)); // constraint writeElement(CSW, "Constraint", () -> { writeAttributes(constraintLangVersion); out().writeNamespace("ogc", OGC); writeElement(OGC, "Filter", () -> { writeElement(OGC, "PropertyIsEqualTo", () -> { writeElement(OGC, "PropertyName", () -> { out().writeCharacters("Identifier"); });//from w ww . j av a 2 s . c om writeElement(OGC, "Literal", () -> { out().writeCharacters(identifier); }); }); }); }); }); }
From source file:edu.internet2.middleware.shibboleth.idp.config.profile.ProfileHandlerGroupBeanDefinitionParser.java
/** {@inheritDoc} */ public BeanDefinition parse(Element config, ParserContext context) { Map<QName, List<Element>> configChildren = XMLHelper.getChildElements(config); List<Element> children; children = configChildren.get(new QName(ProfileHandlerNamespaceHandler.NAMESPACE, "ErrorHandler")); log.debug("{} error handler definitions found", children.size()); SpringConfigurationUtils.parseInnerCustomElement(children.get(0), context); children = configChildren.get(new QName(ProfileHandlerNamespaceHandler.NAMESPACE, "ProfileHandler")); log.debug("{} profile handler definitions found", children.size()); SpringConfigurationUtils.parseInnerCustomElements(children, context); children = configChildren.get(new QName(ProfileHandlerNamespaceHandler.NAMESPACE, "LoginHandler")); log.debug("{} login handler definitions found", children.size()); SpringConfigurationUtils.parseInnerCustomElements(children, context); return null;/*from w ww .ja va 2 s . c o m*/ }
From source file:de.ii.xtraplatform.ogc.api.gml.parser.GMLParser.java
public void parse(ListenableFuture<HttpEntity> entity, String ns, String ft) throws ExecutionException { QName featureType = new QName(ns, ft); LOGGER.debug("Parsing GetFeature response for '{}'", ft); try {// w w w .ja v a 2s . c om ListenableFuture<SMInputCursor> rootFuture = Futures.transform(entity, new Function<HttpEntity, SMInputCursor>() { @Override public SMInputCursor apply(HttpEntity e) { try { return staxFactory.rootElementCursor(e.getContent()).advance(); } catch (IOException | IllegalStateException | XMLStreamException ex) { LOGGER.debug("Error parsing WFS GetFeature (IOException) {}", ex.getMessage()); return null; } } }); parseRoot(rootFuture, ns, ft); } finally { try { EntityUtils.consumeQuietly(entity.get()); } catch (InterruptedException ex) { } } }
From source file:org.eclipse.lyo.client.oslc.samples.DoorsOauthSample.java
/** * Login to the DWA server and perform some OSLC actions * @param args//from ww w. ja v a 2 s .c o m * @throws ParseException */ public static void main(String[] args) throws ParseException { Options options = new Options(); options.addOption("url", true, "url"); options.addOption("user", true, "user ID"); options.addOption("password", true, "password"); options.addOption("project", true, "project area"); CommandLineParser cliParser = new GnuParser(); //Parse the command line CommandLine cmd = cliParser.parse(options, args); if (!validateOptions(cmd)) { logger.severe( "Syntax: java <class_name> -url https://<server>:port/<context>/ -user <user> -password <password> -project \"<project_area>\""); logger.severe( "Example: java DoorsOauthSample -url https://exmple.com:9443/dwa -user ADMIN -password ADMIN -project \"JKE Banking (Requirements Management)\""); return; } String webContextUrl = cmd.getOptionValue("url"); String user = cmd.getOptionValue("user"); String passwd = cmd.getOptionValue("password"); String projectArea = cmd.getOptionValue("project"); try { //STEP 1: Initialize a Jazz rootservices helper and indicate we're looking for the RequirementManagement catalog // The root services for DOORs is found at /public level JazzRootServicesHelper helper = new JazzRootServicesHelper(webContextUrl + "/public", OSLCConstants.OSLC_RM_V2); //STEP 2: Create a new OSLC OAuth capable client, the parameter of following call should be provided // by the system administrator of the DOORs Web Access server OslcOAuthClient client = helper.initOAuthClient("1234567890", "123"); if (client != null) { //STEP 3: Try to access the context URL to trigger the OAuth dance and login try { client.getResource(webContextUrl, OSLCConstants.CT_RDF); } catch (OAuthRedirectException oauthE) { validateTokens(client, oauthE.getRedirectURL() + "?oauth_token=" + oauthE.getAccessor().requestToken, user, passwd, webContextUrl + "/j_acegi_security_check"); // Try to access again ClientResponse response = client.getResource(webContextUrl, OSLCConstants.CT_RDF); response.getEntity(InputStream.class).close(); } //STEP 4: Get the URL of the OSLC catalog String catalogUrl = helper.getCatalogUrl(); //STEP 5: Find the OSLC Service Provider for the project area we want to work with String serviceProviderUrl = lookupServiceProviderUrl(catalogUrl, "Services for " + projectArea, client); //STEP 6: Get the Query Capabilities URL so that we can run some OSLC queries String queryCapability = client.lookupQueryCapability(serviceProviderUrl, OSLCConstants.OSLC_RM_V2, OSLCConstants.RM_REQUIREMENT_TYPE); //STEP 7: Get the Creation Factory URL for default Requirements so that we can create one Requirement requirement = new Requirement(); String requirementFactory = client.lookupCreationFactory(serviceProviderUrl, OSLCConstants.OSLC_RM_V2, requirement.getRdfTypes()[0].toString()); //STEP 8 Get the default Requirement Type URL ResourceShape reqInstanceShape = RmUtil.lookupRequirementsInstanceShapes(serviceProviderUrl, OSLCConstants.OSLC_RM_V2, requirement.getRdfTypes()[0].toString(), client, "Resource shape for a requirement in the " + projectArea); if ((reqInstanceShape != null) && (requirementFactory != null)) { //STEP 9: Create a Requirement requirement.setInstanceShape(reqInstanceShape.getAbout()); // Add a link requirement.addImplementedBy( new Link(new URI("http://google.com"), "Link created by an Eclipse Lyo user")); requirement.setDescription("Created By EclipseLyo"); // Add the PrimaryText String primaryText = "My Eclipse Lyo CREATED Primary Text"; Element obj = RmUtil.convertStringToHTML(primaryText); requirement.getExtendedProperties().put(RmConstants.PROPERTY_PRIMARY_TEXT, obj); //Create the Requirement ClientResponse creationResponse = client.createResource(requirementFactory, requirement, OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_RDF_XML); String req01URL = creationResponse.getHeaders().getFirst(HttpHeaders.LOCATION); creationResponse.consumeContent(); } //STEP 10: Query of changed values OslcQueryParameters queryParams = new OslcQueryParameters(); queryParams.setPrefix("oslc_rm=<http://open-services.net/ns/rm#>"); queryParams.setWhere("oslc_rm:implementedBy=<http://google.com>"); OslcQuery query = new OslcQuery(client, queryCapability, 10, queryParams); OslcQueryResult result = query.submit(); boolean processAsJavaObjects = false; int resultsSize = result.getMembersUrls().length; processPagedQueryResults(result, client, processAsJavaObjects); System.out.println("\n------------------------------\n"); System.out.println("Number of Results for query 1 = " + resultsSize + "\n"); //STEP 11: Now get the artifact with identifier = 9 queryParams = new OslcQueryParameters(); queryParams.setPrefix("dcterms=<http://purl.org/dc/terms/>"); queryParams.setWhere("dcterms:identifier=9"); query = new OslcQuery(client, queryCapability, 10, queryParams); result = query.submit(); String requirementURL = null; // Get the URL of returned requirement if (result != null) { String[] returnedURLS = result.getMembersUrls(); if ((returnedURLS != null) && (returnedURLS.length > 0)) { requirementURL = returnedURLS[0]; } } // STEP 12 If requirement found, lets get it an modify if (requirementURL != null) { // Get the requirement ClientResponse getResponse = client.getResource(requirementURL, OslcMediaType.APPLICATION_RDF_XML); requirement = getResponse.getEntity(Requirement.class); // Get the eTAG, we need it to update String etag = getResponse.getHeaders().getFirst(OSLCConstants.ETAG); getResponse.consumeContent(); // Following code is needed to workaround an issue in DWA that exposes the Heading inf as encoded XML { // Get the type for "Object Heading" org.eclipse.lyo.oslc4j.core.model.Property[] properties = reqInstanceShape.getProperties(); String attrDef = null; for (org.eclipse.lyo.oslc4j.core.model.Property property : properties) { if (property.getTitle().equalsIgnoreCase("Object Heading")) { attrDef = property.getPropertyDefinition().toString(); } } if (attrDef != null) { String url = attrDef.substring(0, attrDef.lastIndexOf("/") + 1); String name = attrDef.substring(attrDef.lastIndexOf("/") + 1); // QName attr12Name = new QName("https://slot12.gdl.mex.ibm.com:8443/dwa/rm/urn:rational::1-514b30b9627b2a31-M-00000062/types/", "attrDef-12"); QName attr12Name = new QName(url, name); String attr12 = (String) requirement.getExtendedProperties().get(attr12Name); attr12 = removeXMLEscape(attr12); Element objattr12 = RmUtil.convertStringToHTML(attr12); requirement.getExtendedProperties().put(attr12Name, objattr12); } } // Change the Primary text String primaryText = "My Eclipse Lyo CHANGED Primary Text"; // Put in the proper object ( Element for XML Strings ) Element obj = RmUtil.convertStringToHTML(primaryText); requirement.getExtendedProperties().put(RmConstants.PROPERTY_PRIMARY_TEXT, obj); // Add a couple of links requirement.addImplementedBy(new Link(new URI("http://google.com"), "ImplementedBy example")); requirement.addElaboratedBy(new Link(new URI("http://terra.com.mx"), "ElaboratedBy example")); // Update the requirement with the proper etag ClientResponse updateResponse = client.updateResource(requirementURL, requirement, OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_RDF_XML, etag); updateResponse.consumeContent(); } } } catch (RootServicesException re) { logger.log(Level.SEVERE, "Unable to access the Jazz rootservices document at: " + webContextUrl + "/public/rootservices", re); } catch (Exception e) { logger.log(Level.SEVERE, e.getMessage(), e); } }
From source file:org.javelin.sws.ext.jws.invocation.MessageFactoryTest.java
@Test public void createDocumentWrapper() throws Exception { OperationDescription op = new OperationDescription(); op.setRootName(new QName("urn:test", "document")); WebServiceInvocationMessage message = this.invocationFactory.createInvocation(op); message.getSoapMessage().writeTo(System.out); }