Example usage for javax.xml.namespace QName QName

List of usage examples for javax.xml.namespace QName QName

Introduction

In this page you can find the example usage for javax.xml.namespace QName QName.

Prototype

public QName(final String namespaceURI, final String localPart) 

Source Link

Document

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 .

Usage

From source file:org.kuali.rice.core.framework.resourceloader.RiceSpringResourceLoaderConfigurer.java

public QName getName() {
    if (this.name == null) {
        this.setName(new QName(this.getServiceNameSpaceURI(), this.getLocalServiceName()));
    }/*  www  .  j a  va 2 s.co m*/
    return name;
}

From source file:com.myrealtor.service.external.AxisRPCClient.java

@SuppressWarnings("unchecked")
public List<Apartment> findApartmentList(String username, String zip) throws AxisFault {
    log.debug("findApartmentList providerId: " + username + " - zip: " + zip);

    // QName of the target method
    QName qName = new QName("http://service.apartment.com", "findApartmentByUsername");

    Object[] opFindEntryArgs = new Object[] { username };
    if (zip != null) {
        qName = new QName("http://service.apartment.com", "findApartment");
        opFindEntryArgs = new Object[] { username, zip };
    }/*w ww.  j ava2  s .c o  m*/

    Class[] returnTypes = new Class[] { Apartment[].class };
    //Class[] returnTypes = new Class[] { List.class };

    Object[] response = serviceClient.invokeBlocking(qName, opFindEntryArgs, returnTypes);

    Apartment[] resultArray = (Apartment[]) response[0];
    //log.debug("response: " + response + "  response.length: " + response.length);      

    List result = Arrays.asList(resultArray);

    serviceClient.cleanup();
    serviceClient.cleanupTransport();
    return result;

}

From source file:be.e_contract.mycarenet.sts.EHealthSTSClient.java

/**
 * Main constructor.//from  ww w.  j  a va  2  s. c  o m
 * 
 * @param location
 *            the URL of the eHealth STS web service.
 */
public EHealthSTSClient(String location) {
    EHealthSamlStsService service = EHealthSamlStsServiceFactory.newInstance();

    QName portQName = new QName("urn:be:ehealth:saml:sts:1.0", "EHealthSamlStsPort");
    this.dispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD);

    this.dispatch.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY, location);

    Binding binding = dispatch.getBinding();
    @SuppressWarnings("rawtypes")
    List<Handler> handlerChain = binding.getHandlerChain();
    this.wsSecuritySOAPHandler = new WSSecuritySOAPHandler();
    handlerChain.add(this.wsSecuritySOAPHandler);
    handlerChain.add(new LoggingHandler());
    binding.setHandlerChain(handlerChain);
}

From source file:org.apache.servicemix.http.HttpSpringTest.java

public void test() throws Exception {
    DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
    InOut me = client.createInOutExchange();
    me.setService(new QName("http://test", "MyProviderService"));
    me.getInMessage().setContent(new StringSource("<echo xmlns='http://test'><echoin0>world</echoin0></echo>"));
    client.sendSync(me);//  ww  w .j  av a  2  s  .  c om
    if (me.getStatus() == ExchangeStatus.ERROR) {
        if (me.getFault() != null) {
            fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
        } else if (me.getError() != null) {
            throw me.getError();
        } else {
            fail("Received ERROR status");
        }
    } else {
        logger.info(new SourceTransformer().toString(me.getOutMessage().getContent()));
    }
}

From source file:org.apache.cxf.fediz.service.idp.STSPreAuthAuthenticationProvider.java

@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    // We only handle PreAuthenticatedAuthenticationTokens
    if (!(authentication instanceof PreAuthenticatedAuthenticationToken)) {
        return null;
    }// www  .j  av a 2 s .c o  m

    Bus cxfBus = getBus();
    IdpSTSClient sts = new IdpSTSClient(cxfBus);
    sts.setAddressingNamespace("http://www.w3.org/2005/08/addressing");
    if (tokenType != null && tokenType.length() > 0) {
        sts.setTokenType(tokenType);
    } else {
        sts.setTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
    }
    sts.setKeyType(HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512_BEARER);
    sts.setWsdlLocation(wsdlLocation);
    sts.setServiceQName(new QName(namespace, wsdlService));
    sts.setEndpointQName(new QName(namespace, wsdlEndpoint));

    sts.getProperties().putAll(properties);
    if (use200502Namespace) {
        sts.setNamespace(HTTP_SCHEMAS_XMLSOAP_ORG_WS_2005_02_TRUST);
    }

    if (lifetime != null) {
        sts.setEnableLifetime(true);
        sts.setTtl(lifetime.intValue());
    }

    return handlePreAuthenticated((PreAuthenticatedAuthenticationToken) authentication, sts);
}

From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.attributeDefinition.ScriptedAttributeDefinitionBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(String pluginId, Element pluginConfig, Map<QName, List<Element>> pluginConfigChildren,
        BeanDefinitionBuilder pluginBuilder, ParserContext parserContext) {
    super.doParse(pluginId, pluginConfig, pluginConfigChildren, pluginBuilder, parserContext);

    String scriptLanguage = "javascript";
    if (pluginConfig.hasAttributeNS(null, "language")) {
        scriptLanguage = pluginConfig.getAttributeNS(null, "language");
    }/*from  ww  w  .j av a2s . c  o m*/
    log.debug("Attribute definition {} scripting language: {}", pluginId, scriptLanguage);
    pluginBuilder.addPropertyValue("language", scriptLanguage);

    String script = null;
    List<Element> scriptElem = pluginConfigChildren
            .get(new QName(AttributeDefinitionNamespaceHandler.NAMESPACE, "Script"));
    if (scriptElem != null && scriptElem.size() > 0) {
        script = scriptElem.get(0).getTextContent();
    } else {
        List<Element> scriptFileElem = pluginConfigChildren
                .get(new QName(AttributeDefinitionNamespaceHandler.NAMESPACE, "ScriptFile"));
        if (scriptFileElem != null && scriptFileElem.size() > 0) {
            String scriptFile = scriptFileElem.get(0).getTextContent();
            try {
                script = DatatypeHelper.inputstreamToString(new FileInputStream(scriptFile), null);
            } catch (IOException e) {
                throw new BeanCreationException("Unable to read script file " + scriptFile, e);
            }
        }
    }

    if (script == null) {
        throw new BeanCreationException("No script specified for this attribute definition");
    }
    log.debug("Attribute definition {} script: {}", pluginId, script);
    pluginBuilder.addPropertyValue("script", script);
}

From source file:com.evolveum.midpoint.schema.processor.MidPointSchemaDefinitionFactory.java

private ComplexTypeDefinition createObjectClassDefinition(XSComplexType complexType, PrismContext prismContext,
        XSAnnotation annotation) throws SchemaException {
    QName typeName = new QName(complexType.getTargetNamespace(), complexType.getName());

    ObjectClassComplexTypeDefinition ocDef = new ObjectClassComplexTypeDefinition(typeName, prismContext);

    // nativeObjectClass
    Element nativeAttrElement = SchemaProcessorUtil.getAnnotationElement(annotation,
            MidPointConstants.RA_NATIVE_OBJECT_CLASS);
    String nativeObjectClass = nativeAttrElement == null ? null : nativeAttrElement.getTextContent();
    ocDef.setNativeObjectClass(nativeObjectClass);

    ShadowKindType kind = null;/*from   w  ww.  ja va 2 s  .com*/
    Element kindElement = SchemaProcessorUtil.getAnnotationElement(annotation, MidPointConstants.RA_KIND);
    if (kindElement != null) {
        String kindString = kindElement.getTextContent();
        if (StringUtils.isEmpty(kindString)) {
            throw new SchemaException(
                    "The definition of kind is empty in the annotation of object class " + typeName);
        }
        try {
            kind = ShadowKindType.fromValue(kindString);
        } catch (IllegalArgumentException e) {
            throw new SchemaException("Definition of unknown kind '" + kindString
                    + "' in the annotation of object class " + typeName);
        }
        ocDef.setKind(kind);
    }

    Boolean defaultInAKind = SchemaProcessorUtil.getAnnotationBooleanMarker(annotation,
            MidPointConstants.RA_DEFAULT);
    if (defaultInAKind == null) {
        ocDef.setDefaultInAKind(false);
    } else {
        ocDef.setDefaultInAKind(defaultInAKind);
    }

    Boolean auxiliary = SchemaProcessorUtil.getAnnotationBooleanMarker(annotation,
            MidPointConstants.RA_AUXILIARY);
    if (auxiliary == null) {
        ocDef.setAuxiliary(false);
    } else {
        ocDef.setAuxiliary(auxiliary);
    }

    String intent = null;
    Element intentElement = SchemaProcessorUtil.getAnnotationElement(annotation, MidPointConstants.RA_INTENT);
    if (intentElement != null) {
        intent = intentElement.getTextContent();
        if (StringUtils.isEmpty(intent)) {
            throw new SchemaException(
                    "The definition of intent is empty in the annotation of object class " + typeName);
        }
        ocDef.setIntent(intent);
    }

    // accountType: DEPRECATED
    if (isAccountObject(annotation)) {
        if (kind != null && kind != ShadowKindType.ACCOUNT) {
            throw new SchemaException(
                    "Conflicting definition of kind and legacy account annotation in the annotation of object class "
                            + typeName);
        }
        ocDef.setKind(ShadowKindType.ACCOUNT);
        Element account = SchemaProcessorUtil.getAnnotationElement(annotation, MidPointConstants.RA_ACCOUNT);
        if (account != null && !defaultInAKind) {
            String defaultValue = account.getAttribute("default");
            // Compatibility (DEPRECATED)
            if (defaultValue != null) {
                ocDef.setDefaultInAKind(Boolean.parseBoolean(defaultValue));
            }
        }
        Element accountTypeElement = SchemaProcessorUtil.getAnnotationElement(annotation,
                MidPointConstants.RA_ACCOUNT_TYPE);
        if (accountTypeElement != null) {
            String accountType = accountTypeElement.getTextContent();
            if (intent != null && !intent.equals(accountType)) {
                throw new SchemaException(
                        "Conflicting definition of intent and legacy accountType annotation in the annotation of object class "
                                + typeName);
            }
            ocDef.setIntent(accountType);
        }
    }

    return ocDef;

}

From source file:org.apache.servicemix.http.endpoints.SerializedMarshalerTest.java

public void testUsingSpringHttpRemoting() throws Exception {
    final Person person = new PersonImpl("Hunter", "Thompson", 67);

    // Create a consumer endpoint
    HttpConsumerEndpoint ep = new HttpConsumerEndpoint();
    ep.setService(new QName("urn:HttpConsumer", "HttpConsumer"));
    ep.setEndpoint("HttpConsumer");
    ep.setLocationURI("http://localhost:8192/service/");
    ep.setTargetService(new QName("urn:HttpInvoker", "Endpoint"));

    // Configure the SerializedMarshaler and specifiy it on the endpoint
    SerializedMarshaler marshaler = new SerializedMarshaler();
    marshaler.setDefaultMep(MessageExchangeSupport.IN_OUT);
    ep.setMarshaler(marshaler);//from www.  j av  a  2 s  .c o  m

    // Add the endpoint to the component and activate it
    HttpComponent component = new HttpComponent();
    component.setEndpoints(new HttpEndpointType[] { ep });
    container.activateComponent(component, "HttpConsumer");

    // Dummy up a component as a receiver and route it to urn:HttpInvoker/Endpoint
    TransformComponentSupport rmiComponent = new TransformComponentSupport() {
        protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out)
                throws MessagingException {
            try {
                // Deserialize rmi invocation
                XStream xstream = new XStream(new DomDriver());
                SourceTransformer st = new SourceTransformer();
                Object rmi = xstream.fromXML(st.toString(in.getContent()));

                DefaultRemoteInvocationExecutor executor = new DefaultRemoteInvocationExecutor();
                Object result = executor.invoke((RemoteInvocation) rmi, person);

                // Convert result to an rmi invocation
                RemoteInvocationResult rmiResult = new RemoteInvocationResult(result);
                out.setContent(new StringSource(xstream.toXML(rmiResult)));
            } catch (Exception e) {
                throw new MessagingException(e);
            }

            return true;
        }
    };
    ActivationSpec asReceiver = new ActivationSpec("rmiComponent", rmiComponent);
    asReceiver.setService(new QName("urn:HttpInvoker", "Endpoint"));
    container.activateComponent(asReceiver);

    // Start the JBI container
    container.start();

    // Set up the Spring bean to call into the URL specified for the consumer endpoint
    HttpInvokerProxyFactoryBean pfb = new HttpInvokerProxyFactoryBean();
    pfb.setServiceInterface(Person.class);
    pfb.setServiceUrl("http://localhost:8192/service/");
    pfb.setHttpInvokerRequestExecutor(new SimpleHttpInvokerRequestExecutor());
    pfb.afterPropertiesSet();

    // Grab the object via the proxy factory bean
    Person test = (Person) pfb.getObject();

    // Test getters
    assertEquals("Hunter", test.getGivenName());
    assertEquals("Thompson", test.getSurName());
    assertEquals(67, test.getAge());

    // Test setters
    test.setGivenName("John");
    test.setSurName("Doe");
    test.setAge(34);

    assertEquals(person.getGivenName(), "John");
    assertEquals(person.getSurName(), "Doe");
    assertEquals(person.getAge(), 34);
}

From source file:org.javelin.sws.ext.bind.internal.model.AnalyzeSimpleTypesTest.java

@Test
public void analyzeBuiltInDatatype() throws Exception {
    TypedPatternRegistry context = (TypedPatternRegistry) SweJaxbContextFactory.createContext("", null);

    PropertyCallback<String> pc = new PropertyCallback<String>(context, String.class,
            SweJaxbConstants.XSD_STRING, XmlAccessType.NONE, XmlNsForm.QUALIFIED, XmlNsForm.UNQUALIFIED);
    TypedPattern<String> pattern = pc.analyze();
    assertTrue(pattern.isSimpleType());/*from  ww w  .  j  av  a 2 s. c o m*/
    assertThat(pattern.getJavaType(), equalTo(String.class));
    assertThat(pattern.getSchemaType(), equalTo(new QName(Constants.URI_2001_SCHEMA_XSD, "string")));

    @SuppressWarnings("unchecked")
    Map<Class<?>, TypedPattern<?>> patterns = (Map<Class<?>, TypedPattern<?>>) ReflectionTestUtils
            .getField(context, "patterns");
    TypedPattern<?> pattern2 = patterns.get(String.class);

    assertSame("Primitive and built-in types should be analyzed only at context creation time.", pattern,
            pattern2);
}

From source file:org.maodian.flyingcat.xmpp.state.StreamState.java

private void doHandle(XmppContext context, XMLStreamReader xmlsr, XMLStreamWriter xmlsw)
        throws XMLStreamException {
    xmlsr.nextTag();//  w ww .  ja  v  a  2  s.c o  m
    QName qname = new QName(XmppNamespace.STREAM, "stream");
    if (!xmlsr.getName().equals(qname)) {
        throw new XmppException(StreamError.INVALID_NAMESPACE).set("QName", xmlsr.getName());
    }

    // throw exception if client version > 1.0
    BigDecimal version = new BigDecimal(xmlsr.getAttributeValue("", "version"));
    if (version.compareTo(SUPPORTED_VERSION) > 0) {
        throw new XmppException(StreamError.UNSUPPORTED_VERSION);
    }

    xmlsw.writeStartDocument();
    xmlsw.writeStartElement("stream", "stream", XmppNamespace.STREAM);
    xmlsw.writeNamespace("stream", XmppNamespace.STREAM);
    xmlsw.writeDefaultNamespace(XmppNamespace.CLIENT_CONTENT);

    xmlsw.writeAttribute("id", RandomStringUtils.randomAlphabetic(32));
    xmlsw.writeAttribute("version", "1.0");
    xmlsw.writeAttribute("from", "localhost");
    xmlsw.writeAttribute(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI, "lang", "en");
    String from = xmlsr.getAttributeValue(null, "from");
    if (from != null) {
        xmlsw.writeAttribute("to", from);
    }

    // features
    xmlsw.writeStartElement(XmppNamespace.STREAM, "features");
    writeFeatures(xmlsw);
    xmlsw.writeEndElement();
}