Search in sources :

Example 1 with Message

use of com.sun.xml.ws.wsdl.writer.document.Message in project metro-jax-ws by eclipse-ee4j.

the class WSDLGenerator method generateSOAPMessages.

/**
 * Generates messages for a SOAPBinding
 * @param method The {@link JavaMethod} to generate messages for
 * @param binding The {@link com.sun.xml.ws.api.model.soap.SOAPBinding} to add the generated messages to
 */
protected void generateSOAPMessages(JavaMethodImpl method, com.sun.xml.ws.api.model.soap.SOAPBinding binding) {
    boolean isDoclit = binding.isDocLit();
    // Message message = portDefinitions.message().name(method.getOperation().getName().getLocalPart());
    Message message = portDefinitions.message().name(method.getRequestMessageName());
    extension.addInputMessageExtension(message, method);
    com.sun.xml.ws.wsdl.writer.document.Part part;
    BindingContext jaxbContext = model.getBindingContext();
    boolean unwrappable = true;
    for (ParameterImpl param : method.getRequestParameters()) {
        if (isDoclit) {
            if (isHeaderParameter(param))
                unwrappable = false;
            part = message.part().name(param.getPartName());
            part.element(param.getName());
        } else {
            if (param.isWrapperStyle()) {
                for (ParameterImpl childParam : ((WrapperParameter) param).getWrapperChildren()) {
                    part = message.part().name(childParam.getPartName());
                    part.type(jaxbContext.getTypeName(childParam.getXMLBridge().getTypeInfo()));
                }
            } else {
                part = message.part().name(param.getPartName());
                part.element(param.getName());
            }
        }
    }
    if (method.getMEP() != MEP.ONE_WAY) {
        message = portDefinitions.message().name(method.getResponseMessageName());
        extension.addOutputMessageExtension(message, method);
        for (ParameterImpl param : method.getResponseParameters()) {
            if (isDoclit) {
                part = message.part().name(param.getPartName());
                part.element(param.getName());
            } else {
                if (param.isWrapperStyle()) {
                    for (ParameterImpl childParam : ((WrapperParameter) param).getWrapperChildren()) {
                        part = message.part().name(childParam.getPartName());
                        part.type(jaxbContext.getTypeName(childParam.getXMLBridge().getTypeInfo()));
                    }
                } else {
                    part = message.part().name(param.getPartName());
                    part.element(param.getName());
                }
            }
        }
    }
    for (CheckedExceptionImpl exception : method.getCheckedExceptions()) {
        QName tagName = exception.getDetailType().tagName;
        String messageName = exception.getMessageName();
        QName messageQName = new QName(model.getTargetNamespace(), messageName);
        if (processedExceptions.contains(messageQName))
            continue;
        message = portDefinitions.message().name(messageName);
        extension.addFaultMessageExtension(message, method, exception);
        // tagName.getLocalPart());
        part = message.part().name("fault");
        part.element(tagName);
        processedExceptions.add(messageQName);
    }
}
Also used : Message(com.sun.xml.ws.wsdl.writer.document.Message) QName(javax.xml.namespace.QName) CheckedExceptionImpl(com.sun.xml.ws.model.CheckedExceptionImpl) WrapperParameter(com.sun.xml.ws.model.WrapperParameter) BindingContext(com.sun.xml.ws.spi.db.BindingContext) ParameterImpl(com.sun.xml.ws.model.ParameterImpl)

Aggregations

CheckedExceptionImpl (com.sun.xml.ws.model.CheckedExceptionImpl)1 ParameterImpl (com.sun.xml.ws.model.ParameterImpl)1 WrapperParameter (com.sun.xml.ws.model.WrapperParameter)1 BindingContext (com.sun.xml.ws.spi.db.BindingContext)1 Message (com.sun.xml.ws.wsdl.writer.document.Message)1 QName (javax.xml.namespace.QName)1