Usando resultados de ASP.NET 4.0 WCF en ColdFusion 9

I am consuming a WCF made with ASP.NET 4.0 and trying to use the resulting data in Coldfusion 9.

Using the following code I am able to return what appears to be an object, but not the data itself as XML (as I was expecting).

<cfscript> 
    wcf2 = CreateObject("webservice","http://demo.opendrt.co.uk/Mobisoft.TAPIMobiRouter.WCF.Silver/MBRServices.svc?wsdl", "BasicHttpBinding_IMBRBookingServices");
    variables.myResult2 = wcf2.GetPassengerBookings("Austin,Jason", "14/11/2010", "14/11/2012");
    XMLContent = variables.myResult2.ResponseData.Booking;
</cfscript>

The Booking element of ResponseData contains several entries, each of which contains other data, some of which is nested in further children of booking.

XMLContent = variables.myResult2.ResponseData.getBooking(2).DropOffLocation.ShortName;

Will return the value of that item alone, as will

XMLContent = variables.myResult2.ResponseData.getBooking(2).BookingPassengerInfo.PassengerRef;

Is it possible to use the returned data as a whole, converting it to a recordset or similar within Coldfusion, something along the lines of:

<cfoutput query="XMLContent">
    <h1>#PassengerRef#</h1>
    <p>#ShortName#<p>
</cfoutput>

Gracias paul

preguntado el 08 de noviembre de 11 a las 14:11

1 Respuestas

I have something that works, whether it is the most economical way to achieve it I am not sure so am open to any other ideas.

<cfscript> 
    wcf2 = CreateObject("webservice","http://demo.opendrt.co.uk/Mobisoft.TAPIMobiRouter.WCF.Silver/MBRServices.svc?wsdl", "BasicHttpBinding_IMBRBookingServices");
    variables.myResult2 = wcf2.GetPassengerBookings("Austin,Jason", "14/11/2010", "14/11/2012");
    bookings = variables.myResult2.ResponseData.Booking;
</cfscript>

<cfset result = QueryNew("BookingRef, PassengerRef, PickupDateTime","varchar, varchar, varchar")>

<cfloop from="1" to="#ArrayLen(bookings)#" index="i">
        <!--- Add a row to the query.--->
        <cfset QueryAddRow(result)>
        <cfset QuerySetCell(result, "BookingRef", bookings[i].BookingRef)>
        <cfset QuerySetCell(result, "PassengerRef", bookings[i].BookingPassengerInfo.PassengerRef)>
        <cfset QuerySetCell(result, "PickupDateTime", bookings[i].PickupDateTime)>

</cfloop>

<table>
    <tr>
            <th>Booking Ref</th>
            <th>Passenger Ref</th>
            <th>PickupDateTime</th>
    </tr>
    <cfoutput query="result">
            <tr>
                    <td>#BookingRef#</td>
                    <td>#PassengerRef#</td>
                    <td>#PickupDateTime#</td>
            </tr>
    </cfoutput>
</table>

respondido 09 nov., 11:20

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.