6 Replies Latest reply on Feb 1, 2008 9:34 AM by JR "Bob" Dobbs-qSBHQ2

    Convert XML File

    hhr_jb Level 1
      I have a XML file I need to pass via web services. How can I read, convert the file to a binary data and send it off to the wsdl function? Been working on this all day, googled and no luck. Any help would be greatly appreciated.

      Jimmy
        • 1. Re: Convert XML File
          JR "Bob" Dobbs-qSBHQ2 Level 3
          You might try something like the sample below.

          It might also help if you post both your code, any errors you receive, and the WSDL you are using.
          • 2. Convert XML File
            hhr_jb Level 1
            Thanks for the post. I already have an xml file. How can I read it and then convert it?

            This is what I have so far
            <cfsavecontent variable="myxml">
            <?xml version="1.0" encoding="utf-8"?>
            <ImprintedData xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">
            <CustomerHeader>
            <Version>1.0</Version>
            <CustomerID>2000189</CustomerID>
            <CustomerName>Royal Lahaina</CustomerName>
            <FormID>2001832</FormID>
            <FieldID>2209843</FieldID>
            <sourceCreateTS>2007-10-24T22:1:29</sourceCreateTS>
            <ch_CustomerPrintSite>Hawaii</ch_CustomerPrintSite>
            <ch_CustomerEmpID>123321</ch_CustomerEmpID>
            <ch_CustomerEmpName>Melody Jones</ch_CustomerEmpName>
            </CustomerHeader>
            <Transaction TransactionID="E3C20CE4-113C-4CF1-A404-TID3">
            <DigitalID>1052RN</DigitalID>
            <FormFields>
            <FormField name ="RoomType">T1KOL</FormField>
            <FormField name ="RatePackage">CIGMSO</FormField>
            <FormField name ="RoomNumber">8011</FormField>
            <FormField name ="ArrivalDate">10/16/07</FormField>
            <FormField name ="DepartureDate">10/19/07</FormField>
            <FormField name ="GuestName">Alualu, Taavao</FormField>
            <FormField name ="Address">1440 Ahonui St</FormField>
            <FormField name ="City">Honolulu</FormField>
            <FormField name ="State">HI</FormField>
            <FormField name ="Zip">96819</FormField>
            <FormField name ="PhoneNumber">808-847-7028</FormField>
            <FormField name ="Email">soliduso001@yahoo.com</FormField>
            <FormField name ="ReservationNotes">Garden</FormField>
            <FormField name ="SP">True</FormField>
            <FormField name ="VP">False</FormField>
            </FormFields>
            </Transaction>
            </ImprintedData>
            </cfsavecontent>
            <cfset binaryValue=ToBinary(ToBase64(myxml)) />


            <cfinvoke
            webservice=" http://voyager3.expedata.net/ExpeData_DAWS/DAWS.asmx?WSDL"
            method="sendData" returnvariable="sendDataRet">
            <cfinvokeargument name="sessionID" value="Profile.SessionID"/>
            <cfinvokeargument name="batchID" value="Profile.BatchID"/>
            <cfinvokeargument name="dataArray" value="#BinaryValue#"/>
            <cfinvokeargument name="moreDataFlg" value="Profile.MoreDataFlag"/>
            <cfinvokeargument name="dataFileSize" value="#dirlist.size#"/>
            <cfinvokeargument name="errorMsg" value="#Profile.ErrorMsg#"/>
            </cfinvoke>

            I'm getting the following error
            Web service operation "sendData" with parameters {moreDataFlg={Profile.MoreDataFlag},errorMsg={ },batchID={Profile.BatchID},dataArray={[B@1d5d6d0},dataFileSize={},sessionID={Profile.Ses sionID}} could not be found.


            The error occurred in D:\Inetpub\wwwroot\SMSReg\WDSL\Test1.cfm: line 134

            132 : <cfinvokeargument name="moreDataFlg" value="Profile.MoreDataFlag"/>
            133 : <cfinvokeargument name="dataFileSize" value="#dirlist.size#"/>
            134 : <cfinvokeargument name="errorMsg" value="#Profile.ErrorMsg#"/>
            135 : </cfinvoke>
            136 :



            Jimmy
            • 3. Re: Convert XML File
              JR "Bob" Dobbs-qSBHQ2 Level 3
              Try:
              1. Putting pound signs around all of your cfinvokeargument variables, unless you want to pass the string "Profile.SessionID" as a value. For example the value of the moreDataFlg argument should be boolean, not a string.

              2. Matching the case of method and variables names from the WSDL: "SendData", not "sendData"

              • 4. Re: Convert XML File
                JR "Bob" Dobbs-qSBHQ2 Level 3
                quote:

                Thanks for the post. I already have an xml file. How can I read it and then convert it?


                If the XML files exists on the file system you can read it to a variable with the cffile tag.
                • 5. Re: Convert XML File
                  hhr_jb Level 1
                  That is correct I'm trying to pass the string as a value/reference, That's why I didn't at the pound sign.

                  As for the boolean how do pass a boolean? I thought you just pass it as false.

                  I changed the matching case and same error

                  I also read the xml file and converted it over to a binary and passed it through. Unless you can see something wrong w/ this code, I'm having a feeling the problem is on the wsdl's end.

                  <CFFile action="read" file="d:\inetpub\wwwroot\smsreg\wdsl\10507S.xml" variable="MyReadXMLFile">
                  <cfset binaryValue1=ToBinary(tobase64(myreadxmlfile)) />

                  <cfinvoke
                  webservice=" http://voyager3.expedata.net/ExpeData_DAWS/DAWS.asmx?WSDL"
                  method="SendData" returnvariable="sendDataRet">
                  <cfinvokeargument name="sessionID" value="Profile.SessionID"/>
                  <cfinvokeargument name="batchID" value="Profile.BatchID"/>
                  <cfinvokeargument name="dataArray" value="#BinaryValue1#"/>
                  <cfinvokeargument name="moreDataFlg" value="Profile.MoreDataFlag"/>
                  <cfinvokeargument name="dataFileSize" value="#dirlist.size#"/>
                  <cfinvokeargument name="errorMsg" value="#Profile.ErrorMsg#"/>
                  </cfinvoke>

                  <CFOUTPUT>#sendDataRet#</CFOUTPUT>

                  Jimmy
                  • 6. Convert XML File
                    JR "Bob" Dobbs-qSBHQ2 Level 3
                    Your code is sending the value "Profile.MoreDataFlag" where a boolean is expected.

                    Edit: replaced "quotes" with "pound signs" in next paragraph

                    Assuming you have a struct that looks like the one below you still need to enclose the cfinvokeargument values in pound signs else the literal value "Profile.MoreDataFlag" will be used in place of the boolean value false.

                    <cfset Profile=StructNew() />
                    <cfset Profile.SessionID="SAMPLE" />
                    <cfset Profile.BatchID="ABC123" />
                    <cfset Profile.MoreDataFlag=false />
                    <cfset Profile.ErrorMsg="BR549" />




                    <cfinvoke
                    webservice=" http://voyager3.expedata.net/ExpeData_DAWS/DAWS.asmx?WSDL"
                    method="SendData" returnvariable="sendDataRet">
                    <cfinvokeargument name="sessionID" value="#Profile.SessionID#"/>
                    <cfinvokeargument name="batchID" value="#Profile.BatchID#"/>
                    <cfinvokeargument name="dataArray" value="#BinaryValue1#"/>
                    <cfinvokeargument name="moreDataFlg" value="#Profile.MoreDataFlag#"/>
                    <cfinvokeargument name="dataFileSize" value="#dirlist.size#"/>
                    <cfinvokeargument name="errorMsg" value="#Profile.ErrorMsg#"/>
                    </cfinvoke>

                    If I am incorrect as to the purpose of the Profile.* values please provide further explanation and code.