Java Code Examples for javax.wsdl.Definition#createMessage()

The following examples show how to use javax.wsdl.Definition#createMessage() . 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
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Message addRequestMessage( Definition localDef, OperationDeclaration op ) {

		Message inputMessage = localDef.createMessage();
		inputMessage.setUndefined( false );

		Part inputPart = localDef.createPart();
		inputPart.setName( "body" );
		try {
			// adding wsdl_types related to this message
			if( op instanceof OneWayOperationDeclaration ) {
				OneWayOperationDeclaration op_ow = (OneWayOperationDeclaration) op;

				// set the message name as the name of the jolie request message type
				inputMessage.setQName( new QName( tns, op_ow.requestType().id() ) );
				addMessageType( op_ow.requestType(), op_ow.id() );

			} else {
				RequestResponseOperationDeclaration op_rr = (RequestResponseOperationDeclaration) op;
				// set the message name as the name of the jolie request message type
				inputMessage.setQName( new QName( tns, op_rr.requestType().id() ) );
				addMessageType( op_rr.requestType(), op_rr.id() );

			}
			// set the input part as the operation name
			inputPart.setElementName( new QName( tnsSchema, op.id() ) );

			inputMessage.addPart( inputPart );
			inputMessage.setUndefined( false );

			localDef.addMessage( inputMessage );
		} catch( Exception e ) {
			e.printStackTrace();
		}
		return inputMessage;
	}
 
Example 2
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Message addResponseMessage( Definition localDef, OperationDeclaration op ) {

		Message outputMessage = localDef.createMessage();
		outputMessage.setUndefined( false );

		Part outputPart = localDef.createPart();
		outputPart.setName( "body" );

		// adding wsdl_types related to this message
		try {
			RequestResponseOperationDeclaration op_rr = (RequestResponseOperationDeclaration) op;
			String outputPartName = op_rr.id() + "Response";
			// set the message name as the name of the jolie response message type
			outputMessage.setQName( new QName( tns, op_rr.responseType().id() ) );
			addMessageType( op_rr.responseType(), outputPartName );

			outputPart.setElementName( new QName( tnsSchema, outputPartName ) );

			outputMessage.addPart( outputPart );
			outputMessage.setUndefined( false );

			localDef.addMessage( outputMessage );
		} catch( Exception e ) {
			e.printStackTrace();
		}
		return outputMessage;

	}
 
Example 3
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Message addFaultMessage( Definition localDef, TypeDefinition tp ) {
	Message faultMessage = localDef.createMessage();
	faultMessage.setUndefined( false );

	// set the fault message name as the name of the fault jolie message type
	faultMessage.setQName( new QName( tns, tp.id() ) );

	Part faultPart = localDef.createPart();
	faultPart.setName( "body" );

	String faultPartName = tp.id();

	try {
		// adding wsdl_types related to this message
		addMessageType( tp, faultPartName );

		faultPart.setElementName( new QName( tnsSchema, faultPartName ) );
		faultMessage.addPart( faultPart );
		faultMessage.setUndefined( false );

		localDef.addMessage( faultMessage );
	} catch( Exception e ) {
		e.printStackTrace();
	}
	return faultMessage;

}
 
Example 4
Source File: XTeeWsdlDefinition.java    From j-road with Apache License 2.0 5 votes vote down vote up
private void addXRoadExtensions(Definition definition) throws WSDLException {
  definition.addNamespace(XROAD_PREFIX, XROAD_NAMESPACE);

  Message message = definition.createMessage();
  message.setQName(new QName(definition.getTargetNamespace(), XROAD_HEADER));

  addXroadHeaderPart(definition, message, XTeeHeader.CLIENT);
  addXroadHeaderPart(definition, message, XTeeHeader.SERVICE);
  addXroadHeaderPart(definition, message, XTeeHeader.ID);
  addXroadHeaderPart(definition, message, XTeeHeader.USER_ID);
  addXroadHeaderPart(definition, message, XTeeHeader.PROTOCOL_VERSION);

  message.setUndefined(false);
  definition.addMessage(message);

  // Add XRoad schema import to the first schema
  for (Object ex : definition.getTypes().getExtensibilityElements()) {
    if (ex instanceof Schema) {
      Schema schema = (Schema) ex;
      Element xRoadImport =
          schema.getElement().getOwnerDocument().createElement(schema.getElement().getPrefix() == null
                                                                                                       ? "import"
                                                                                                       : schema.getElement().getPrefix()
                                                                                                           + ":import");
      xRoadImport.setAttribute("namespace", XROAD_NAMESPACE);
      xRoadImport.setAttribute("schemaLocation", XROAD_NAMESPACE);
      schema.getElement().insertBefore(xRoadImport, schema.getElement().getFirstChild());
      break;
    }
  }
}
 
Example 5
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected void buildService(ServiceInfo serviceInfo, Definition definition) {

        Map<QName, MessageInfo> messages = serviceInfo.getMessages();
        for (Map.Entry<QName, MessageInfo> mie : messages.entrySet()) {
            if (!mie.getKey().getNamespaceURI().equals(definition.getTargetNamespace())) {
                continue;
            }
            if (definition.getMessage(mie.getKey()) != null) {
                continue;
            }
            Message message = definition.createMessage();
            addDocumentation(message, mie.getValue().getMessageDocumentation());
            message.setUndefined(false);
            message.setQName(mie.getKey());
            for (MessagePartInfo mpi : mie.getValue().getMessageParts()) {
                Part part = definition.createPart();
                boolean elemental = mpi.isElement();
                // RFSB will turn on isElement bogusly.
                if (elemental
                    && null == serviceInfo.getXmlSchemaCollection().
                        getElementByQName(mpi.getElementQName())) {
                    elemental = false;
                }
                if (elemental) {
                    part.setElementName(mpi.getElementQName());
                } else {
                    part.setTypeName(mpi.getTypeQName());
                }
                part.setName(mpi.getName().getLocalPart());
                message.addPart(part);
            }

            definition.addMessage(message);
        }

        addDocumentation(definition, serviceInfo.getTopLevelDoc());
        Service serv = definition.createService();
        addDocumentation(serv, serviceInfo.getDocumentation());
        serv.setQName(serviceInfo.getName());
        addNamespace(serviceInfo.getName().getNamespaceURI(), definition);
        addExtensibilityElements(definition, serv, getWSDL11Extensors(serviceInfo));
        definition.addService(serv);

        for (EndpointInfo ei : serviceInfo.getEndpoints()) {
            addNamespace(ei.getTransportId(), definition);
            Port port = definition.createPort();
            addDocumentation(port, ei.getDocumentation());
            port.setName(ei.getName().getLocalPart());
            port.setBinding(definition.getBinding(ei.getBinding().getName()));
            addExtensibilityElements(definition, port, getWSDL11Extensors(ei));
            serv.addPort(port);
        }
    }
 
Example 6
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected void buildPortTypeOperation(PortType portType,
                                      Collection<OperationInfo> operationInfos,
                                      final Definition def) {
    for (OperationInfo operationInfo : operationInfos) {
        Operation operation = null;
        try {
            operation = operationInfo.getProperty(
                WSDLServiceBuilder.WSDL_OPERATION, Operation.class);
        } catch (ClassCastException e) {
            // do nothing
        }

        if (operation == null) {
            operation = def.createOperation();
            addDocumentation(operation, operationInfo.getDocumentation());
            operation.setUndefined(false);
            operation.setName(operationInfo.getName().getLocalPart());
            addNamespace(operationInfo.getName().getNamespaceURI(), def);
            if (operationInfo.isOneWay()) {
                operation.setStyle(OperationType.ONE_WAY);
            }
            addExtensibilityElements(def, operation, getWSDL11Extensors(operationInfo));
            Input input = def.createInput();
            addDocumentation(input, operationInfo.getInput().getDocumentation());
            input.setName(operationInfo.getInputName());
            Message message = def.createMessage();
            buildMessage(message, operationInfo.getInput(), def);
            this.addExtensibilityAttributes(def, input, getInputExtensionAttributes(operationInfo));
            this.addExtensibilityElements(def, input, getWSDL11Extensors(operationInfo.getInput()));
            input.setMessage(message);
            operation.setInput(input);
            operation.setParameterOrdering(operationInfo.getParameterOrdering());

            if (operationInfo.getOutput() != null) {
                Output output = def.createOutput();
                addDocumentation(output, operationInfo.getOutput().getDocumentation());
                output.setName(operationInfo.getOutputName());
                message = def.createMessage();
                buildMessage(message, operationInfo.getOutput(), def);
                this.addExtensibilityAttributes(def, output, getOutputExtensionAttributes(operationInfo));
                this.addExtensibilityElements(def, output, getWSDL11Extensors(operationInfo.getOutput()));
                output.setMessage(message);
                operation.setOutput(output);
            }
            //loop to add fault
            Collection<FaultInfo> faults = operationInfo.getFaults();
            Fault fault = null;
            for (FaultInfo faultInfo : faults) {
                fault = def.createFault();
                addDocumentation(fault, faultInfo.getDocumentation());
                fault.setName(faultInfo.getFaultName().getLocalPart());
                message = def.createMessage();
                buildMessage(message, faultInfo, def);
                this.addExtensibilityAttributes(def, fault, faultInfo.getExtensionAttributes());
                this.addExtensibilityElements(def, fault, getWSDL11Extensors(faultInfo));
                fault.setMessage(message);
                operation.addFault(fault);
            }
        }
        portType.addOperation(operation);
    }
}