This example demonstrate the usage of content modifier step, to set and get header, property and body. IFlow consist of 2 content modifier steps and log01, log02 script steps.

Click on any blank area in iflow, then set the namespace like below. Set the namespace same like namespace in WSDL file.

The sender soap channel is using another “PC.WSDL”. See the PC’s xml schema structure and example xml message in SOAPUI at the end of this post.

PC.wsdl

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.test.com/PC/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="PC" targetNamespace="http://www.test.com/PC/">
	<wsdl:types>
		<xsd:schema targetNamespace="http://www.test.com/PC/">
			<xsd:element name="Create">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="record" maxOccurs="1" minOccurs="0">
							<xsd:complexType>
								<xsd:sequence>
									<xsd:element name="price" maxOccurs="1" minOccurs="0" type="xsd:string"/>
									<xsd:element name="record" maxOccurs="unbounded" minOccurs="0">
										<xsd:complexType>
											<xsd:sequence>
												<xsd:element name="part" maxOccurs="unbounded" minOccurs="0">
													<xsd:complexType>
														<xsd:sequence>
															<xsd:element name="type" maxOccurs="1" minOccurs="0" type="xsd:string"/>
															<xsd:element name="quantity" maxOccurs="1" minOccurs="0" type="xsd:string"/>
															<xsd:element name="uom" maxOccurs="1" minOccurs="0" type="xsd:string"/>
														</xsd:sequence>
													</xsd:complexType>
												</xsd:element>
											</xsd:sequence>
										</xsd:complexType>
									</xsd:element>
								</xsd:sequence>
							</xsd:complexType>
						</xsd:element>
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
			<xsd:element name="CreateResponse">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="out" type="xsd:string"/>
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
		</xsd:schema>
	</wsdl:types>
	<wsdl:message name="CreateRequest">
		<wsdl:part element="tns:Create" name="parameters"/>
	</wsdl:message>
	<wsdl:message name="CreateResponse">
		<wsdl:part element="tns:CreateResponse" name="parameters"/>
	</wsdl:message>
	<wsdl:portType name="PC">
		<wsdl:operation name="Create">
			<wsdl:input message="tns:CreateRequest"/>
			<wsdl:output message="tns:CreateResponse"/>
		</wsdl:operation>
	</wsdl:portType>
	<wsdl:binding name="PCSOAP" type="tns:PC">
		<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
		<wsdl:operation name="Create">
			<soap:operation soapAction="http://www.test.com/PC/Create"/>
			<wsdl:input>
				<soap:body use="literal"/>
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal"/>
			</wsdl:output>
		</wsdl:operation>
	</wsdl:binding>
	<wsdl:service name="PC">
		<wsdl:port binding="tns:PCSOAP" name="PCSOAP">
			<soap:address location="http://www.example.org/"/>
		</wsdl:port>
	</wsdl:service>
</wsdl:definitions>

The script is reusing existing script like previous Post, but added “logging” checking if value equal to ‘true’:
If logging set to ‘true’, then only header, property logging and payload attachment will happen during runtime.

First content modifier:
Header:
Set header.price with XPath
Set header.title with Constant value
Set header.logging with External Parameter

For XPath, after namespace set correctly, able to choose from dropdown list:

Steps to set External parameter: Go to tab “Externalized Parameters”, set the value, then click save icon and right side.

Property:
Set property.msg with expression build-in ${in.body}
Set property.footer with Constant value.

Body: is remain default without set anything.

Second content modifier:
Header:
Set header.logging_copy by reusing value from header.logging.

Property:
Set property.footer_copy by reusing value from property.footer.

Body: Read all header, property set in 1st and 2nd content modifier step, then set them in body combine with xml structure below:

Input and Output result using SOAPUI:

In my view, Content Modifier is very useful for variable-like setting/getting tasks, and provide a very flexible way to manually set the output body using WYSIWYG way, very intuitive. However for programmatically read and set output payload, other steps like Mapping or Scripting is better option.

Content Modifier to Get Input/Set Output using Type Constant, XPath, Expression, Header, Property and Externalized Parameters
Tagged on:             

2 thoughts on “Content Modifier to Get Input/Set Output using Type Constant, XPath, Expression, Header, Property and Externalized Parameters

  • October 6, 2017 at 10:22 am
    Permalink

    Nice article. I am creating an external parameter for the content modifier but when I deploy this, it still does not show up in the Web UI. Are there any special steps that need to be done for this to show in the Web UI?

    Reply
  • November 6, 2019 at 9:53 pm
    Permalink

    Excellent article, very good for PO/HCI/CPI Developers.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *