none
Silverlight - Exchange EWS RRS feed

  • Question

  • Hi,

    I read that it is possible to connect to Exchange EWS from Silverlight application. (http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/8ef61823-4a5b-4638-828a-917304f26755)

    But i have problem with it.

    I created web reference to the service. Sample code:

    BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
    binding.MaxReceivedMessageSize = int.MaxValue;
    EndpointAddress address = new EndpointAddress(new Uri("https://red002.mail.emea.microsoftonline.com/ews/exchange.asmx"));
    ExchangeService.ExchangeServicePortTypeClient proxy = new ExchangeServicePortTypeClient(binding, address);
    proxy.ClientCredentials.UserName.UserName = "user";
    proxy.ClientCredentials.UserName.Password = "password";
    GetUserAvailabilityRequestType art = new GetUserAvailabilityRequestType();
    /**********/
    /*... some code populating request...*/
    /**********/
    proxy.GetUserAvailabilityCompleted += new EventHandler<GetUserAvailabilityCompletedEventArgs>(completedEvent);
    proxy.GetUserAvailabilityAsync(art);

     

    clientaccesspolicy.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <access-policy>
      <cross-domain-access>
        <policy>
          <allow-from http-request-headers="*">
            <domain uri="*"/>
          </allow-from>
          <grant-to>
            <resource path="*" include-subpaths="true"/>
          </grant-to>
        </policy>
      </cross-domain-access>
    </access-policy>

     

    And I get:

    System.ServiceModel.CommunicationException: An error occurred while trying to make a request to URI 'https://red002.mail.emea.microsoftonline.com/ews/exchange.asmx'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details. ---> System.Security.SecurityException ---> System.Security.SecurityException: Security error.
       w System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)

     

    Can anybody help me solve this problem?


    MW
    Friday, April 1, 2011 10:43 AM

All replies