Skip to content

Latest commit

 

History

History
56 lines (54 loc) · 2.07 KB

apikit-set-header-task.adoc

File metadata and controls

56 lines (54 loc) · 2.07 KB

To Set a SOAP Header

In this procedure, you add header information to the outbound response that complies with the WSDL. Header information that complies with the WSDL document is called APIUsageInformation.

  1. In Studio, open the tshirt2.wsdl in src/main/wsdl and scroll to APIUsageInformation element, which is the element expected by the contract. Copy the name of the element to the clipboard.

  2. On the canvas, select Transform message in the OrderTshirt:/TshirtService/TshirtServicePort/api-config flow, and in the properties editor, click Add New Target:

    apikit-for-soap-3005f
  3. Select Property instead of Variable from the drop-down.

  4. In Variable Name, paste the contents of the clipboard, and add soap. as a prefix. or type soap.APIUsageInformation.

    The complete variable name looks like this:

    soap.APIUsageInformation

  5. Click OK.

  6. Double-click apiCallsRemaining: Integer.

    apikit-for-soap-41732

    Double-clicking apiCallsRemaining: Integer adds APIUsageInformation: { apiCallsRemaining: null } to the DataWeave code for the outbound property:

    %dw 1.0
    %output application/xml
    %namespace ns0 http://mulesoft.org/tshirt-service
    ---
    {
      ns0#APIUsageInformation: {
        apiCallsRemaining: null
      }
    }
  7. Change null to 10.

  8. Save and rerun the project.

  9. In the SoapUI, execute the OrderTshirt request again. The response envelope from APIkit for SOAP is:

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
       <soap:Header>
          <ns0:APIUsageInformation xmlns:ns0="http://mulesoft.org/tshirt-service">
             <apiCallsRemaining>10</apiCallsRemaining>
          </ns0:APIUsageInformation>
       </soap:Header>
       <soap:Body>
          <ns0:OrderTshirtResponse xmlns:ns0="http://mulesoft.org/tshirt-service">
             <orderId>I got a request from John, using the following auth header 987654321</orderId>
          </ns0:OrderTshirtResponse>
       </soap:Body>
    </soap:Envelope>