2013-11-01 1 views
1

Мне нужна небольшая рука для конвертации тегов CFML cfexchange в API EWS. Я использую CF 9.0.1 и вам нужно добавить элементы почты/календаря на размещенный сервер Exchange.CFML и Exchange - теги CFexchange перестали работать

я получаю следующее сообщение об ошибке:

Error: 
Could not log in to the Exchange server. 
________________________________________ 
connection="exchangeConn" 
server="EXVMBX016-5.exch016.msoutlookonline.net" 
username="exch016\j_ttt" 
mailboxname="[email protected]" 
password="[removed]" 
Protocol="http" 
port="80" 
formbasedauthentication="TRUE" 
formbasedauthenticationURL="https://owa016.msoutlookonline.net/owa/auth/logon.aspx" 


Я придумал следующий код до сих пор;

<cffunction name="EWSAddEvent" output="false" returntype="Boolean"> 
    <!--- EWS added by vjl 2013/10/31 ---> 
    <!--- 
     CFExchange in CF server 9 or older will not talk with Exchange 2010 at all, it is promissed to be fixed in CF 10. 
     As a solution you can use the EWS API. Read the stuff below. I hope my hint is helpfull to you. 
     ---------------------------------------------------------------------- ---------------------- 
     With Exchange 2007 Microsoft abandoned WebDav as an interface to Exchangeserver. 
     The standard Coldfusion Tags relied on WebDav and will not work anymore. 
     Since I needed a way to interface with Exchange Server a started looking for possible solutions and this is what i came up with. 
     In december 2010 Microsoft released the Exchange Managed Services Library for java. 
     You can find it here: http://archive.msdn.microsoft.com/ewsjavaapi/Release/ProjectReleases.a spx?ReleaseId=5691 
     In the getting started document it tells you it depends on 4 3rd party libraries which you need to be download separately: 
     - Apache Commons HttpClient 3.1 (commons-httpclient-3.1.jar) 
     - Apache Commons Codec 1.4 (commons-codec-1.4.jar) 
     - Apache Commons Logging 1.1.1 (commons-codec-1.4.jar) 
     - JCIFS 1.3.15 (jcifs-1.3.15.jar) 
     With Coldfusion 9.1 (the version I tested with) you only need 
     - JCIFS 1.3.15 (jcifs-1.3.15.jar) which you can download here: http://jcifs.samba.org/src/ 
     Place the EWS Jar and the JCIFS Jar in your Coldfusion libray folder and after restarting CF server the following code should work. 
     If you understand this you will be able to figure out your specific needs from the EWS API documentation. 
     ---> 
    <cfargument name="EmailAddress" type="String" required="True" /> 
    <cfargument name="EventName" type="String" /> 
    <cfargument name="EventStartDateTime" type="Date" /> 
    <cfargument name="EventEndDateTime" type="Date" /> 
    <cfargument name="EventSubject" type="String" /> 
    <cfargument name="EventDescription" type="String" /> 
    <cfargument name="EventLocation" type="String" Required="False" Default="" /> 
    <!--- <cfargument name="EventSensitivity" type="String" Required="False" Default="Normal" /> 
     <cfargument name="EventImportance" type="String" Required="False" Default="Normal" /> ---> 
    <cfargument name="EventReminder" type="String" Required="False" default=0 /> 
    <!--- <cfargument name="Organizer" type="String" Required="False" Default="" /> ---> 
    <cfargument name="OptionalAttendees" type="String" Required="False" Default="" /> 
    <cfargument name="leadID" type="numeric" required="no" default="0" /> 
    <cfargument name="serviceID" type="numeric" required="no" default="0" /> 
    <cfargument name="userID" type="numeric" required="no" default="0" /> 
    <cfargument name="companyID" type="numeric" required="no" default="0" /> 
    <cfargument name="serviceTypeID" type="numeric" required="no" default="0" /> 
    <cfmail to="[email protected]" from="[email protected]" subject="Exchange EWSAddEvent debug Arguments" type="html"><cfdump var="#Arguments#"></cfmail> 
    <!--- Build Mailbox ---> 
    <cfset UserName = Left(Arguments.EmailAddress,Find("@",Arguments.EmailAddress)-1) /> 
    <cfset Arguments.UserName = Application.Exchange.Domain & "\" & lcase(UserName) & Application.Exchange.MailboxPostFix /> 
    <cfset Arguments.Pword = Trim(FetchExchangePassword(Arguments.EmailAddress)) />   
    <!--- 1. I need an instance of the ExchangeService class ---> 
    <cfobject type="Java" class="microsoft.exchange.webservices.data.ExchangeService" name="service"> 
    <cfset service.init()> 
    <cfmail to="[email protected]" from="[email protected]" subject="Exchange EWSAddEvent debug service" type="html"><cfdump var="#service#"></cfmail> 
    <!--- 2. I need to set the credentials ---> 
    <!--- 2a. Create an instance of the WebCredentials class ---> 
    <cfobject type="Java" class="microsoft.exchange.webservices.data.WebCredentials" name="credentials"> 
    <!--- 2b. Set the credentials ---> 
    <cfset credentials.init("#arguments.UserName#","#Arguments.Pword#", "t.com")> 
    <!--- 2c. Set the credentials in the service object ---> 
    <cfset service.setCredentials(credentials) /> 
    <!--- 3. In need to set the URL to Exchange (stay away from autodsicovery) ---> 
    <!--- 3a. Create an instance of the Uri class ---> 
    <cfobject type="Java" class="java.net.URI" name="uri"> 
    <!--- 3b. Set the full path ---> 
    <cfset uri.init("https://mail.t.com/ews/Exchange.asmx")> 
    <!--- 3c. Set the url in the service object ---> 
    <cfset service.setUrl(uri) /> 
    <!--- These are the steps you need to create valid a service object. ---> 
    <!--- Now we need to do something with it. ---> 
    <!--- I create a test message to my own mailbox to see if it works ---> 
    <cfobject type="Java" action="create" class="microsoft.exchange.webservices.data.EmailMessage" name="message"> 
    <cfset message = message.init(service) /> 
    <cfset message.SetSubject("EWSTest")> 
    <cfset messageBody = CreateObject("java", "microsoft.exchange.webservices.data.MessageBody")> 
    <cfset messageBody.init("My EWS test message")> 
    <cfset message.SetBody(messageBody)> 
    <cfset message.ToRecipients.Add("[email protected]") > 
    <cfmail to="[email protected]" from="[email protected]" subject="Exchange EWSAddEvent debug message" type="html"><cfdump var="#message#"></cfmail> 
    <cfoutput> 
     #message.SendAndSaveCopy()# 
    </cfoutput> 
    <cfreturn True /> 
</cffunction> 
+0

Ничего. Абсолютно ничего. – user990016

+0

Ну, это выходные; Я подозреваю, что большинство людей, которые занимаются Exchange, делают это как часть своей работы, и, таким образом, гораздо меньше людей хотят даже посмотреть на нее на fri/sat/sun. Я добавил несколько тегов, которые должны обладать большей видимостью. –

+0

Кроме того, [этот вопрос] (http://stackoverflow.com/questions/14652813/ews-api-and-coldfusion-how-to-reference-returned-values), как представляется, имеет рабочий код для подключения к EWS от CF - может быть, попробовать? –

ответ

0

Получили ли вы какую-либо операцию для работы с использованием EWS? Или вы сталкиваетесь с проблемой при попытке отправить почту? Если EWS сам не работает, вы можете попробовать следующий фрагмент кода (изменить URL, имя пользователя и пароль) кода?

<cfscript> 
service = createObject("java", "microsoft.exchange.webservices.data.ExchangeService"); 
service.init(); 
serviceURI = createObject("java", "java.net.URI"); 
serviceURI.init("http://10.192.37.30/ews/Exchange.asmx"); 
service.setUrl(serviceURI); 
credentials = createObject("java", "microsoft.exchange.webservices.data.WebCredentials"); 
credentials.init("user", "password"); 
service.setCredentials(credentials); 
folderAPI = createObject("java", "microsoft.exchange.webservices.data.Folder"); 

folderName = createObject("java", "microsoft.exchange.webservices.data.WellKnownFolderName"); 

result = folderAPI.bind(service, folderName.Inbox); 
writeOutput(result.getDisplayName()); 

Соответствующий код Java является

ExchangeService service = new ExchangeService(); 
URI url = new URI("http://10.192.37.30/ews/Exchange.asmx"); 
service.setUrl(url); 
service.setCredentials(new WebCredentials("username", "password")); 
System.out.println("Created ExchangeService"); 
Folder folder = Folder.bind(service, WellKnownFolderName.Inbox); 
System.out.println(folder.getDisplayName()); 

Если это работает, можно попробовать более сложные операции.

Убедитесь, что вы используете правильный URL-адрес ASMX, имя пользователя и пароль. Попробуйте получить доступ к URL-адресу в браузере. Укажите имя пользователя и пароль. Если вы можете увидеть WSDL, тогда все в порядке.

Также убедитесь, что вы используете базовую проверку подлинности в Exchange Server.

Thanks, Paul

+0

Я ждал все это время, чтобы заставить мой сервер (LayeredTech) ответить. Я не могу пинговать сервер обмена с моего веб-сервера. Они не могут понять, почему и что изменилось, чтобы привести к сбою подключения. Я вернусь к вам. – user990016

+0

Я полностью потерял этот пост. Я начал новую запись по тому же вопросу. – user990016

 Смежные вопросы

  • Нет связанных вопросов^_^