Java Code Examples for javax.xml.namespace.QName

The following examples show how to use javax.xml.namespace.QName. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
final QName parseElementName(XmlElementDecl e) {
    String local = e.name();
    String nsUri = e.namespace();
    if(nsUri.equals("##default")) {
        // if defaulted ...
        XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,
            nav().getDeclaringClassForMethod(method),this);
        if(xs!=null)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
Example 2
Source Project: openjdk-jdk9   Source File: RELAXNGCompiler.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void mapToClass(DElementPattern p) {
    NameClass nc = p.getName();
    if(nc.isOpen())
        return;   // infinite name. can't map to a class.

    Set<QName> names = nc.listNames();

    CClassInfo[] types = new CClassInfo[names.size()];
    int i=0;
    for( QName n : names ) {
        // TODO: read class names from customization
        String name = model.getNameConverter().toClassName(n.getLocalPart());

        bindQueue.put(
            types[i++] = new CClassInfo(model,pkg,name,p.getLocation(),null,n,null,null/*TODO*/),
            p.getChild() );
    }

    classes.put(p,types);
}
 
Example 3
@Test(groups = "wso2.esb", description = "- Logging proxy" + "- Publish WSDL Options - Specified source url")
public void testLoggingProxy() throws Exception {

    OMElement response = axis2Client
            .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("wsdlOptionsFromSourceUrlLoggingProxy"), null,
                    "WSO2");

    String lastPrice = response.getFirstElement()
            .getFirstChildWithName(new QName("http://services.samples/xsd", "last")).getText();
    assertNotNull(lastPrice, "Fault: response message 'last' price null");

    String symbol = response.getFirstElement()
            .getFirstChildWithName(new QName("http://services.samples/xsd", "symbol")).getText();
    assertEquals(symbol, "WSO2", "Fault: value 'symbol' mismatched");

}
 
Example 4
Source Project: hottub   Source File: HttpAdapterList.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a PortAddressResolver that maps portname to its address
 *
 * @param endpointImpl application endpoint Class that eventually serves the request.
 */
public PortAddressResolver createPortAddressResolver(final String baseAddress, final Class<?> endpointImpl) {
    return new PortAddressResolver() {
        @Override
        public String getAddressFor(@NotNull QName serviceName, @NotNull String portName) {
            String urlPattern = addressMap.get(new PortInfo(serviceName,portName, endpointImpl));
            if (urlPattern == null) {
                //if a WSDL defines more ports, urlpattern is null (portName does not match endpointImpl)
                //so fallback to the default behaviour where only serviceName/portName is checked
                for (Entry<PortInfo, String> e : addressMap.entrySet()) {
                    if (serviceName.equals(e.getKey().serviceName) && portName.equals(e.getKey().portName)) {
                            urlPattern = e.getValue();
                            break;
                    }
                }
            }
            return (urlPattern == null) ? null : baseAddress+urlPattern;
        }
    };
}
 
Example 5
private static String convert(Object obj) {
   try {
      Class clazz = obj.getClass();
      if (!jaxbContextMap.containsKey(clazz)) {
         jaxbContextMap.put(clazz, JAXBContext.newInstance(clazz));
      }

      JAXBContext context = (JAXBContext)jaxbContextMap.get(clazz);
      Marshaller marshaller = context.createMarshaller();
      StringWriter writer = new StringWriter();
      if (obj.getClass().isAnnotationPresent(XmlRootElement.class)) {
         marshaller.marshal(obj, (Writer)writer);
      } else if (obj.getClass().isAnnotationPresent(XmlType.class)) {
         JAXBElement jaxbElement = new JAXBElement(new QName("", obj.getClass().getSimpleName()), clazz, obj);
         marshaller.marshal(jaxbElement, (Writer)writer);
      }

      return writer.toString();
   } catch (Exception var6) {
      LOG.error(var6.getMessage(), var6);
      Assert.fail(var6.getMessage());
      return null;
   }
}
 
Example 6
Source Project: lams   Source File: SOAPHelper.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get a header block from the SOAP envelope contained within the specified message context's
 * {@link MessageContext#getOutboundMessage()}.
 * 
 * @param msgContext the message context being processed
 * @param headerName the name of the header block to return 
 * @param targetNodes the explicitly specified SOAP node actors (1.1) or roles (1.2) for which the header is desired
 * @param isFinalDestination true specifies that headers targeted for message final destination should be returned,
 *          false specifies they should not be returned
 * @return the list of matching header blocks
 */
public static List<XMLObject> getOutboundHeaderBlock(MessageContext msgContext, QName headerName,
        Set<String> targetNodes, boolean isFinalDestination) {
    XMLObject outboundEnvelope = msgContext.getOutboundMessage();
    if (outboundEnvelope == null) {
        throw new IllegalArgumentException("Message context does not contain an outbound SOAP envelope");
    }
    
    // SOAP 1.1 Envelope
    if (outboundEnvelope instanceof Envelope) {
        return getSOAP11HeaderBlock((Envelope) outboundEnvelope, headerName, targetNodes, isFinalDestination);
    }
    
    //TODO SOAP 1.2 support when object providers are implemented
    return Collections.emptyList();
}
 
Example 7
Source Project: hottub   Source File: WSDLGenerator.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected void generateSOAPHeaders(TypedXmlWriter writer, List<ParameterImpl> parameters, QName message) {

        for (ParameterImpl headerParam : parameters) {
            Header header = writer._element(Header.class);
            header.message(message);
            header.part(headerParam.getPartName());
            header.use(LITERAL);
        }
    }
 
Example 8
@Override
public SDDocument resolve(String systemId) {
    SDDocument sdi = docs.get(systemId);
    if (sdi == null) {
        SDDocumentSource sds;
        try {
            sds = SDDocumentSource.create(new URL(systemId));
        } catch(MalformedURLException e) {
            throw new WebServiceException(e);
        }
        sdi = SDDocumentImpl.create(sds, new QName(""), new QName(""));
        docs.put(systemId, sdi);
    }
    return sdi;
}
 
Example 9
@Test(groups = "wso2.esb", description = "Tests-Replace out going message envelop")
public void testReplaceEnvelop() throws AxisFault {

    response = axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp("enrichReplaceEnvelopTestProxy"), null, "WSO2");
    assertNotNull(response, "Response is null");
    assertEquals(response.getQName().getLocalPart(), "getQuote");
    assertEquals(response.getFirstElement().getLocalName().toString(),
                 "request", "Local name does not match");
    assertEquals(response.getFirstElement().getFirstChildWithName
            (new QName("http://services.samples", "symbol")).getText(),
                 "WSO2", "Tag does not match");
}
 
Example 10
public Fitness validateServerSide(PolicyAssertion assertion) {
    QName assertionName = assertion.getName();
    if (serverSideSupportedAssertions.contains(assertionName)) {
        return Fitness.SUPPORTED;
    } else if (clientSideSupportedAssertions.contains(assertionName)) {
        return Fitness.UNSUPPORTED;
    } else {
        return Fitness.UNKNOWN;
    }
}
 
Example 11
private QName addPortEpr(WSEndpointReference wsepr) {
    if (wsepr == null)
        throw new WebServiceException(ProviderApiMessages.NULL_EPR());
    QName eprPortName = getPortNameFromEPR(wsepr, null);
    //add Port, if it does n't exist;
    // TODO: what if it has different epr address?
    {
        PortInfo portInfo = new PortInfo(this, (wsepr.getAddress() == null) ? null : EndpointAddress.create(wsepr.getAddress()), eprPortName,
                getPortModel(wsdlService, eprPortName).getBinding().getBindingId());
        if (!ports.containsKey(eprPortName)) {
            ports.put(eprPortName, portInfo);
        }
    }
    return eprPortName;
}
 
Example 12
public static OMElement serialize(RealmConfiguration realmConfig) {
    OMFactory factory = OMAbstractFactory.getOMFactory();

    // add the user store manager properties
    OMElement userStoreManagerElement = factory.createOMElement(new QName(
            UserCoreConstants.RealmConfig.LOCAL_NAME_USER_STORE_MANAGER));
    addPropertyElements(factory, userStoreManagerElement, realmConfig.getUserStoreClass(), realmConfig.getUserStoreProperties());

    return userStoreManagerElement;
}
 
Example 13
Source Project: openjdk-8   Source File: AssertionData.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * A helper method that appends indented string representation of this instance to the input string buffer.
 *
 * @param indentLevel indentation level to be used.
 * @param buffer buffer to be used for appending string representation of this instance
 * @return modified buffer containing new string representation of the instance
 */
public StringBuffer toString(final int indentLevel, final StringBuffer buffer) {
    final String indent = PolicyUtils.Text.createIndent(indentLevel);
    final String innerIndent = PolicyUtils.Text.createIndent(indentLevel + 1);
    final String innerDoubleIndent = PolicyUtils.Text.createIndent(indentLevel + 2);

    buffer.append(indent);
    if (type == ModelNode.Type.ASSERTION) {
        buffer.append("assertion data {");
    } else {
        buffer.append("assertion parameter data {");
    }
    buffer.append(PolicyUtils.Text.NEW_LINE);

    buffer.append(innerIndent).append("namespace = '").append(name.getNamespaceURI()).append('\'').append(PolicyUtils.Text.NEW_LINE);
    buffer.append(innerIndent).append("prefix = '").append(name.getPrefix()).append('\'').append(PolicyUtils.Text.NEW_LINE);
    buffer.append(innerIndent).append("local name = '").append(name.getLocalPart()).append('\'').append(PolicyUtils.Text.NEW_LINE);
    buffer.append(innerIndent).append("value = '").append(value).append('\'').append(PolicyUtils.Text.NEW_LINE);
    buffer.append(innerIndent).append("optional = '").append(optional).append('\'').append(PolicyUtils.Text.NEW_LINE);
    buffer.append(innerIndent).append("ignorable = '").append(ignorable).append('\'').append(PolicyUtils.Text.NEW_LINE);
    synchronized (attributes) {
        if (attributes.isEmpty()) {
            buffer.append(innerIndent).append("no attributes");
        } else {

            buffer.append(innerIndent).append("attributes {").append(PolicyUtils.Text.NEW_LINE);
            for(Map.Entry<QName, String> entry : attributes.entrySet()) {
                final QName aName = entry.getKey();
                buffer.append(innerDoubleIndent).append("name = '").append(aName.getNamespaceURI()).append(':').append(aName.getLocalPart());
                buffer.append("', value = '").append(entry.getValue()).append('\'').append(PolicyUtils.Text.NEW_LINE);
            }
            buffer.append(innerIndent).append('}');
        }
    }

    buffer.append(PolicyUtils.Text.NEW_LINE).append(indent).append('}');

    return buffer;
}
 
Example 14
private URI createEndpointComponentUri(@NotNull QName serviceName, @NotNull QName portName) {
    StringBuilder sb = new StringBuilder(serviceName.getNamespaceURI()).append("#wsdl11.port(").append(serviceName.getLocalPart()).append('/').append(portName.getLocalPart()).append(')');
    try {
        return new URI(sb.toString());
    } catch (URISyntaxException ex) {
        Logger.getLogger(TubelineAssemblyController.class).warning(
                TubelineassemblyMessages.MASM_0020_ERROR_CREATING_URI_FROM_GENERATED_STRING(sb.toString()),
                ex);
        return null;
    }
}
 
Example 15
Source Project: jdk8u60   Source File: Body1_2Impl.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected SOAPElement addElement(QName name) throws SOAPException {
    if (hasFault()) {
        log.severe("SAAJ0402.ver1_2.only.fault.allowed.in.body");
        throw new SOAPExceptionImpl(
            "No other element except Fault allowed in SOAPBody");
    }
    return super.addElement(name);
}
 
Example 16
Source Project: openjdk-jdk8u   Source File: HeaderList.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
    public Set<QName> getUnderstoodHeaders() {
        Set<QName> understoodHdrs = new HashSet<QName>();
        for (int i = 0; i < size(); i++) {
            if (isUnderstood(i)) {
                Header header = get(i);
                understoodHdrs.add(new QName(header.getNamespaceURI(), header.getLocalPart()));
            }
        }
        return understoodHdrs;
//        throw new UnsupportedOperationException("getUnderstoodHeaders() is not implemented by HeaderList");
    }
 
Example 17
Source Project: openjdk-jdk9   Source File: WSDLModelImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
public @NotNull Map<QName, ? extends EditableWSDLBoundPortType> getBindings() {
    return unmBindings;
}
 
Example 18
Source Project: openjdk-8   Source File: SOAP11Fault.java    License: GNU General Public License v2.0 4 votes vote down vote up
QName getFaultcode() {
    return faultcode;
}
 
Example 19
Source Project: TencentKona-8   Source File: WSEndpoint.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static @NotNull QName getDefaultPortName(@NotNull QName serviceName, Class endpointClass, MetadataReader metadataReader) {
    return getDefaultPortName(serviceName, endpointClass, true, metadataReader);
}
 
Example 20
Source Project: openjdk-8   Source File: WSDLModeler.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected Operation processSOAPOperation() {
    Operation operation =
            new Operation(new QName(null, info.bindingOperation.getName()), info.bindingOperation);

    setDocumentationIfPresent(
            operation,
            info.portTypeOperation.getDocumentation());

    if (info.portTypeOperation.getStyle()
            != OperationStyle.REQUEST_RESPONSE
            && info.portTypeOperation.getStyle() != OperationStyle.ONE_WAY) {
        if (options.isExtensionMode()) {
            warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName()));
            return null;
        } else {
            error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName(),
                    info.port.resolveBinding(document).resolvePortType(document).getName()));
        }
    }

    SOAPStyle soapStyle = info.soapBinding.getStyle();

    // find out the SOAP operation extension, if any
    SOAPOperation soapOperation =
            (SOAPOperation) getExtensionOfType(info.bindingOperation,
                    SOAPOperation.class);

    if (soapOperation != null) {
        if (soapOperation.getStyle() != null) {
            soapStyle = soapOperation.getStyle();
        }
        if (soapOperation.getSOAPAction() != null) {
            operation.setSOAPAction(soapOperation.getSOAPAction());
        }
    }

    operation.setStyle(soapStyle);

    String uniqueOperationName =
            getUniqueName(info.portTypeOperation, info.hasOverloadedOperations);
    if (info.hasOverloadedOperations) {
        operation.setUniqueName(uniqueOperationName);
    }

    info.operation = operation;

    //attachment
    SOAPBody soapRequestBody = getSOAPRequestBody();
    if (soapRequestBody == null) {
        // the WSDL document is invalid
        error(info.bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_INPUT_MISSING_SOAP_BODY(info.bindingOperation.getName()));
    }

    if (soapStyle == SOAPStyle.RPC) {
        if (soapRequestBody.isEncoded()) {
            if(options.isExtensionMode()){
                warning(soapRequestBody, ModelerMessages.WSDLMODELER_20_RPCENC_NOT_SUPPORTED());
                processNonSOAPOperation();
            }else{
                error(soapRequestBody, ModelerMessages.WSDLMODELER_20_RPCENC_NOT_SUPPORTED());
            }
        }
        return processLiteralSOAPOperation(StyleAndUse.RPC_LITERAL);
    }
    // document style
    return processLiteralSOAPOperation(StyleAndUse.DOC_LITERAL);
}
 
Example 21
Source Project: Bytecoder   Source File: StreamReaderDelegate.java    License: Apache License 2.0 4 votes vote down vote up
public QName getAttributeName(int index) {
  return reader.getAttributeName(index);
}
 
Example 22
Source Project: openjdk-jdk9   Source File: Body1_1Impl.java    License: GNU General Public License v2.0 4 votes vote down vote up
public SOAPFault addSOAP12Fault(QName faultCode, String faultReason, Locale locale) {
    // log message here
    throw new UnsupportedOperationException("Not supported in SOAP 1.1");
}
 
Example 23
public FaultElement1_1Impl(SOAPDocumentImpl ownerDoc, QName qname) {
    super(ownerDoc, qname);
}
 
Example 24
Source Project: steady   Source File: SP12Constants.java    License: Apache License 2.0 4 votes vote down vote up
public QName getSamlToken() {
    return SAML_TOKEN;
}
 
Example 25
Source Project: openjdk-8   Source File: BindingSubject.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static BindingSubject createInputMessageSubject(QName bindingName, QName operationName, QName messageName) {
    final BindingSubject operationSubject = createOperationSubject(bindingName, operationName);
    return new BindingSubject(messageName, WsdlMessageType.INPUT, WsdlNameScope.MESSAGE, operationSubject);
}
 
Example 26
Source Project: openjdk-8   Source File: Name.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a {@link QName} from this.
 */
public QName toQName() {
    return new QName(nsUri,localName);
}
 
Example 27
Source Project: openjdk-jdk9   Source File: Name.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a {@link QName} from this.
 */
public QName toQName() {
    return new QName(nsUri,localName);
}
 
Example 28
Source Project: steady   Source File: X509Token.java    License: Apache License 2.0 4 votes vote down vote up
public QName getRealName() {
    return constants.getX509Token();
}
 
Example 29
Source Project: jdk8u60   Source File: DataSourceDispatch.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Deprecated
public DataSourceDispatch(QName port, Service.Mode mode, WSServiceDelegate service, Tube pipe, BindingImpl binding, WSEndpointReference epr) {
   super(port, mode, service, pipe, binding, epr );
}
 
Example 30
Source Project: openjdk-jdk9   Source File: WSDLFaultImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
@NotNull
public QName getQName() {
    return new QName(operation.getName().getNamespaceURI(), name);
}