• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Convert XML File

New Here ,
Jan 31, 2008 Jan 31, 2008

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

541

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 31, 2008 Jan 31, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 31, 2008 Jan 31, 2008

Copy link to clipboard

Copied

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.SessionID}} 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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 31, 2008 Jan 31, 2008

Copy link to clipboard

Copied

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"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 31, 2008 Jan 31, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 01, 2008 Feb 01, 2008

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 01, 2008 Feb 01, 2008

Copy link to clipboard

Copied

LATEST
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation