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:in.gov.uidai.auth.aua.httpclient.AuthClient.java

private String generateSignedAuthXML(Auth auth) throws JAXBException, Exception {
    StringWriter authXML = new StringWriter();

    JAXBElement authElement = new JAXBElement(
            new QName("http://www.uidai.gov.in/authentication/uid-auth-request/1.0", "Auth"), Auth.class, auth);

    JAXBContext.newInstance(Auth.class).createMarshaller().marshal(authElement, authXML);
    boolean includeKeyInfo = true;

    if (System.getenv().get("SKIP_DIGITAL_SIGNATURE") != null) {
        return authXML.toString();
    } else {/*from   w  w w .j a  v a 2  s. c om*/
        return this.digitalSignator.signXML(authXML.toString(), includeKeyInfo);
    }
}

From source file:org.javelin.sws.ext.bind.jaxb.JaxbTest.java

@Test(expected = IllegalAnnotationsException.class)
public void marshalMixed() throws Exception {
    JAXBContext ctx = JAXBContext.newInstance(org.javelin.sws.ext.bind.jaxb.context4.MyClassJ4.class);
    Marshaller m = ctx.createMarshaller();
    m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

    org.javelin.sws.ext.bind.jaxb.context4.MyClassJ4 mc4 = new org.javelin.sws.ext.bind.jaxb.context4.MyClassJ4();
    m.marshal(new JAXBElement<org.javelin.sws.ext.bind.jaxb.context4.MyClassJ4>(new QName("a", "a"),
            org.javelin.sws.ext.bind.jaxb.context4.MyClassJ4.class, mc4), System.out);
}

From source file:org.apache.servicemix.camel.JbiInOnlyWithFaultHandledTrueSpringDSLTest.java

@Override
protected void appendJbiActivationSpecs(List<ActivationSpec> activationSpecList) {
    activationSpecList//w  w w .  ja v  a  2s. co m
            .add(createActivationSpec(new ReturnFaultComponent(), new QName("urn:test", "faulty-service")));

    activationSpecList.add(createActivationSpec(receiver, new QName("urn:test", "receiver-service")));
    activationSpecList.add(createActivationSpec(deadLetter, new QName("urn:test", "deadLetter-service")));
}

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

@Test
public void handleXmlAccessTypeProperty() throws Exception {
    // f3, f4, p1, p2, p3, p4 - properties and annotated fields
    System.out.println("\nC3");
    JAXBContext.newInstance(C3.class).createMarshaller()
            .marshal(new JAXBElement<C3>(new QName("", "r"), C3.class, new C3()), System.out);
    JAXBContext ctx = SweJaxbContextFactory.createContext(new Class[] { C3.class }, null);
    Map<Class<?>, TypedPattern<?>> patterns = (Map<Class<?>, TypedPattern<?>>) ReflectionTestUtils.getField(ctx,
            "patterns");
    ComplexTypePattern<C3> pattern = (ComplexTypePattern<C3>) patterns.get(C3.class);
    Map<QName, PropertyMetadata<C3, ?>> elements = (Map<QName, PropertyMetadata<C3, ?>>) ReflectionTestUtils
            .getField(pattern, "elements");
    assertThat(elements.size(), equalTo(6));
    assertTrue(elements.containsKey(new QName("", "f3")));
    assertTrue(elements.containsKey(new QName("", "f4")));
    assertTrue(elements.containsKey(new QName("", "p1")));
    assertTrue(elements.containsKey(new QName("", "p2")));
    assertTrue(elements.containsKey(new QName("", "p3")));
    assertTrue(elements.containsKey(new QName("", "p4")));
}

From source file:be.fedict.eid.idp.protocol.ws_federation.sts.WSSecuritySoapHandler.java

@Override
public Set<QName> getHeaders() {
    Set<QName> headers = new HashSet<QName>();
    headers.add(new QName(WSTrustConstants.WS_SECURITY_NAMESPACE, "Security"));
    return headers;
}

From source file:se.vgregion.portal.patientcontext.SearchControllerTest.java

@Test
public void testSearchEventFirstSearch() throws Exception {
    SearchPatientFormBean formBean = new SearchPatientFormBean();
    formBean.setSearchText("191212121212");
    PatientContext pCtx = new PatientContext();
    MockActionResponse mockRes = new MockActionResponse();
    MockPortletPreferences mockPrefs = new MockPortletPreferences();

    controller.searchEvent(formBean, pCtx, mockRes, mockPrefs);

    assertNotNull(pCtx.getCurrentPatient());
    assertEquals(1, pCtx.getPatientHistorySize());
    assertEquals(1, pCtx.getPatientHistory().size());
    assertTrue(mockRes.getEventNames().hasNext());
    PatientEvent patient = (PatientEvent) mockRes
            .getEvent(new QName("http://vgregion.se/patientcontext/events", "pctx.change"));
    assertSame(patient, pCtx.getCurrentPatient());
    assertSame(patient, pCtx.getPatientHistory().get(0));
}

From source file:com.evolveum.midpoint.repo.sql.OrgClosureTest.java

private void addExtensionProperty(PrismObject object, String name, Object value) throws SchemaException {
    String NS = "http://example.com/p";
    PrismProperty p = object.findOrCreateProperty(new ItemPath(UserType.F_EXTENSION, new QName(NS, name)));
    p.setRealValue(value);//from w w w .  j  a  va 2s .c om
}

From source file:com.wandrell.example.swss.test.util.test.unit.client.AbstractTestEntityClientHeader.java

/**
 * Tests that the client parses correctly formed SOAP messages.
 *
 * @throws IOException/*from   ww  w . j a v a2s .  co m*/
 *             if there is any problem loading the entity schema file
 */
@Test
public final void testClient_Header_Valid() throws IOException {
    final MockWebServiceServer mockServer; // Mocked server
    final RequestMatcher requestMatcher; // Matcher for the request
    final ResponseCreator responseCreator; // Creator for the response
    final ExampleEntity result; // Queried entity

    // Creates the request matcher
    requestMatcher = RequestMatchers.soapHeader(new QName(secHeaderUri, secHeaderLocalPart));

    // Creates the response
    responseCreator = ResponseCreators.withPayload(new ClassPathResource(responsePayloadPath));

    // Creates the server mock
    mockServer = MockWebServiceServer.createServer(client);
    mockServer.expect(requestMatcher).andRespond(responseCreator);

    // Calls the server mock
    result = client.getEntity("http:somewhere.com", entityId);

    Assert.assertEquals(result.getId(), entityId);
    Assert.assertEquals(result.getName(), entityName);

    mockServer.verify();
}

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

public void testSoap() throws Exception {
    final AtomicReference<String> soapAction = new AtomicReference<String>();

    EchoComponent echo = new EchoComponent();
    echo.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "EchoService"));
    echo.setEndpoint("service");
    container.activateComponent(echo, "echo");

    HttpComponent http = new HttpComponent();

    HttpConsumerEndpoint ep0 = new HttpConsumerEndpoint();
    ep0.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "PersonService"));
    ep0.setEndpoint("consumer");
    ep0.setTargetService(new QName("http://servicemix.apache.org/samples/wsdl-first", "EchoService"));
    ep0.setTargetEndpoint("service");
    ep0.setLocationURI("http://localhost:8192/PersonService/");
    ep0.setMarshaler(new DefaultHttpConsumerMarshaler() {
        public MessageExchange createExchange(HttpServletRequest request, ComponentContext context)
                throws Exception {
            soapAction.set(request.getHeader("SOAPAction"));
            return super.createExchange(request, context); //To change body of overridden methods use File | Settings | File Templates.
        }/*from w ww . j a  v a 2 s  .c  om*/
    });

    HttpSoapProviderEndpoint ep1 = new HttpSoapProviderEndpoint();
    ep1.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "PersonService"));
    ep1.setEndpoint("soap");
    ep1.setWsdl(new ClassPathResource("person.wsdl"));
    ep1.setValidateWsdl(false); // TODO: Soap 1.2 not handled yet
    ep1.setUseJbiWrapper(true);

    http.setEndpoints(new HttpEndpointType[] { ep0, ep1 });
    container.activateComponent(http, "http");

    container.start();

    ServiceMixClient client = new DefaultServiceMixClient(container);
    InOut me = client.createInOutExchange();
    me.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "PersonService"));
    me.setOperation(new QName("http://servicemix.apache.org/samples/wsdl-first", "GetPerson"));
    me.getInMessage().setContent(
            new StringSource("<jbi:message xmlns:jbi=\"http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper\""
                    + "             xmlns:msg=\"http://servicemix.apache.org/samples/wsdl-first/types\" "
                    + "             name=\"Hello\" " + "             type=\"msg:HelloRequest\" "
                    + "             version=\"1.0\">" + "  <jbi:part>"
                    + "    <msg:GetPerson><msg:personId>id</msg:personId></msg:GetPerson>" + "  </jbi:part>"
                    + "</jbi:message>"));
    client.sendSync(me);
    client.done(me);
    assertEquals("\"urn:myaction\"", soapAction.get());
}

From source file:com.evolveum.midpoint.testing.sanity.ModelClientUtil.java

public static QName getTypeQName(Class<? extends ObjectType> type) {
    //      QName typeQName = JAXBUtil.getTypeQName(type);
    QName typeQName = new QName(NS_COMMON, type.getSimpleName());
    return typeQName;
}