From: sinetec on
Hi
I try to consume a MS Exchange 2007 webservice to get the 'free/busy'
information out of calendars. But as I understand the login fails on the
windows authentication.
I scanned the web for a solution for quite a while now but I can not find
anything usefull. Is there a recommended solution using CF ?
My code basically looks simple:

<cfinvoke username="mydomain\myusername" password="mypassword"
webservice="https://msexchangeserver/ews/Services.wsdl"
method="GetUserAvailability"
returnvariable="tmp">
</cfinvoke>

The error is:

Error: 401 Unauthorized.

I have no problem to access the WSDL using the browser and I implemented the
required certificate to the CF server.
Unfortunatelly I can not change anything on the Exchange server since it is
not under my control.

many thanks for any idea
Roman

From: "JR "Bob" Dobbs" on
I haven't used Exchange 2007's web services but I'll share my thoughts.

<ShotInTheDark>
CFINVOKE is passing the username and password as basic authentication info. I
expect that you can view the WSDL in Internet Explorer because IE supports
Windows integrated authentication.
I expect that you would need to configure the Exchange web service to allow
basic authentication to be used.
</ShotInTheDark>

If you resolve this issue please post your solution to the forums.

From: sinetec on
Thanks Bob, I fully agree to your thoughts. I havent seen the 'cfinvoke and
basic authentication' in the documentation but it might be - as it is stated
for the cfhttp.

The exchange server unfortunatelly is 'far away' from me at a large enterprise
and there is no way for a basic authentication.

Maybe I should look for a 'connector object' written in .NET or similar...
(currently we use a COM object acting on CDO but Exchange 2007 doesnt like CDO
anymore)

From: cftoaster on
Hey Sintec,

The only way I've been able to connect to Exchange web services, outside of
developing a dotnet class, is this way:

<cfset xbuf = "<?xml version='1.0' encoding='utf-8'?>">
<cfset xbuf = xbuf & "<soap:Envelope
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' ">
<cfset xbuf = xbuf & "xmlns:xsd='http://www.w3.org/2001/XMLSchema' ">
<cfset xbuf = xbuf & "xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' ">
<cfset xbuf = xbuf &
"xmlns:t='http://schemas.microsoft.com/exchange/services/2006/types'>">
<cfset xbuf = xbuf & "<soap:Body>">
<cfset xbuf = xbuf & "<CreateItem SendMeetingInvitations='SendToNone'
xmlns='http://schemas.microsoft.com/exchange/services/2006/messages' ">
<cfset xbuf = xbuf &
"xmlns:t='http://schemas.microsoft.com/exchange/services/2006/types' ">
<cfset xbuf = xbuf & "MessageDisposition='SaveOnly'>">
<cfset xbuf = xbuf & "<Items>">
<cfset xbuf = xbuf & "<t:Task>">
<cfset xbuf = xbuf & "<t:Subject>My task</t:Subject>">
<cfset xbuf = xbuf & "<t:DueDate>2007-12-03T21:32:52</t:DueDate>">
<cfset xbuf = xbuf & "<t:Status>NotStarted</t:Status>">
<cfset xbuf = xbuf & "</t:Task>">
<cfset xbuf = xbuf & "<t:CalendarItem>">
<cfset xbuf = xbuf & "<t:Subject>My Calendar Item</t:Subject>">
<cfset xbuf = xbuf & "<t:Start>2007-12-03T21:32:52</t:Start>">
<cfset xbuf = xbuf & "<t:End>2007-12-03T21:32:52</t:End>">
<cfset xbuf = xbuf & "<t:IsAllDayEvent>1</t:IsAllDayEvent>">
<cfset xbuf = xbuf & "</t:CalendarItem>">
<cfset xbuf = xbuf & "</Items>">
<cfset xbuf = xbuf & "</CreateItem>">
<cfset xbuf = xbuf & "</soap:Body>">
<cfset xbuf = xbuf & "</soap:Envelope>">

<cfscript>
exchangeservice = createobject("com","microsoft.xmlhttp");

exchangeservice.Open("post","https://serverurl",False,"domain\userid","password
");
exchangeservice.setRequestHeader("Content-Type","text/xml");
exchangeservice.setRequestHeader("translate","F");
exchangeservice.send(xbuf);
xmlobj = exchangeservice.responsetext;
writeoutput(exchangeservice.status);
writeoutput(exchangeservice.responsetext);
</cfscript>

<cfset responsexml = xmlparse(xmlobj)>

<cfset itemcodes =
responsexml["soap:Envelope"]["soap:Body"]["m:CreateItemResponse"]["m:ResponseMes
sages"]["m:CreateItemResponseMessage"]["m:Items"]["t:Task"]["t:ItemId"].XmlAttri
butes>

<cfoutput>
<br>TaskID: #itemcodes.Id#
<br>ChangeKey: #itemcodes.ChangeKey#
</cfoutput>

The above sends an xml string to the service and retrieves the item id &
change key (needed for updates). A successful transaction returns a status
code of 200. If you get anything else, do a <cfdump> of the responsexml and
you'll find fairly useful error info.

I've tried the dotnet route, which actually worked quite well (hats off to the
CF8 team for adding this!), but I got tired of trying to translate C# examples
to VB in the Exchange 2007 SDK.

Hope this helps :)

From: sinetec on
Hi cftoaster

thanks for this scary example ! I did some excercises on it and gathered my
first 'msxml' experiences... I now act on Win2003 with the latest msxml6
version (and CF8).
And I think I managed to implement the required certificate. At least I could
get rid of the error "The certificate authority is invalid or incorrect" when
invoking the 'send' method.
The 'send' method executes now and I get a response - but still an error:
"HTTP/1.1 403 Forbidden". I'm not sure whether this response really is from the
exchange server. And I currently have no ideas (and nerves) on what to try
further...

I did try the new 'cfexchange' tag of CF8 that worked from scratch (cool thing
!). This lets me feel the access to the exchange server basically is ok (I used
the same machines and accounts - but I dont know what techniques the
'cfexchange' uses).
Unfortunatelly the 'cfexecute' does not provide the "UserAvailability"
information, so I require to find a solution for those web services.

would you have a guess on where the "HTTP/1.1 403 Forbidden" error originates ?

thanks