0
votes

I've got a .NET web service that has a method that accepts a string. In Mulesoft's Anypoint studio, I've successfully built a flow that accepts a POST, passes the POSTed string into the service, and returns a manipulated result.

I'm now trying to create a flow for a similar service, except that this service accepts a custom object, not a string. When I use SOAP UI to test my service directly, I pass in the following XML and it successfully builds the object in my service and the MyFirstString and MySecondString values are available to the service.

SOAP UI XML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:pra="http://schemas.datacontract.org/2004/07/Pra.Lib.Transformation">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:Transform>         
         <tem:transformationData>            
            <pra:MyFirstString>test1</pra:MyFirstString>
            <pra:MySecondString>test2</pra:MySecondString>
         </tem:transformationData>
      </tem:Transform>
   </soapenv:Body>
</soapenv:Envelope>

However, when I use my Mule flow and drop my DataWeave in front of my Web Service Consumer, it auto-builds an XML string that doesn't work with the service. When I attach a debugger to the service, it shows that the object is not built/mapped successfully...MyFirstString and MySecondString are null after the Web Service Consumer call is made.

DataWeave code:

%dw 1.0
%output application/xml
%namespace ns0 http://tempuri.org/
---
//Some output fields where skipped as the structure is too deep (more than 2 levels).
//To add missing fields click on the scaffold icon (second on the toolbar).
{
    ns0#Transform: {
        ns0#transformationData: {
            Xml: "test1",
            Xslt: "test2"
        }
    }
}

DataWeave output:

<?xml version='1.0' encoding='windows-1252'?>
<ns0:Transform xmlns:ns0="http://tempuri.org/">
  <ns0:transformationData>
    <Xml>test1</Xml>
    <Xslt>test2</Xslt>
  </ns0:transformationData>
</ns0:Transform>

The error message returned is "Error in deserializing body of request message for operation 'Transform'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'Transform' and namespace 'http://tempuri.org/'. Found node type 'Element' with name 'EXTRACT_DETAIL' and namespace ''. Message payload is of type: ElementNSImpl"

So if I understand this error...my question is how do I code the DataWeave to output in the soap envelope format that SOAP UI uses...because it seems that the element structure DataWeave generates is what's giving me problems? Thanks much.

2

2 Answers

0
votes

A fellow developer was able to point me in the right direction. In AnyPoint Studio, on the properties tab for the DataWeave/TransformMessage component, I had to click the button to Scaffold Output Structure. That generated the following output (syntax changes bolded below). I had originally been under the impression that all scaffolding was automatic when first dropping the component into a flow.

Syntax that changed:

                ns1#Xml: "test1",
                ns1#Xslt: "test2"

Entire scaffolding:

%dw 1.0
%output application/xml
%namespace ns0 http://tempuri.org/
---
//Some output fields where skipped as the structure is too deep (more than 2 levels).
//To add missing fields click on the scaffold icon (second on the toolbar).
{
    ns0#Transform: {
        ns0#transformationData: {
            ns1#Xml: "test1",
            ns1#Xslt: "test2"
        }
    }
}

Click here for Scaffold button screen capture

0
votes

Yes after configuring your WSDL you can drag and drop Data Weave and then click on scaffold , it will generate appropriate structure for you.

enter image description here