Flex with WCF Service Over Https – Part 1

Apr 11th, 2010 | By | Category: Web Apps

For the past week I am trying to play around with Flex and find out how it works with different back end service endpoints.In this post I will discuss about how Flex works with a simple WCF Service over HTTPS and also the issues I encountered while doing so.

Okay, so let’s get started with the WCF service first.I have a POCO named Contact which is decorated as a DataContract as shown below:

public class Contact
     [DataMember ]
     public string Name { get; set; }
     public string Email { get; set; }
     public string ContactType { get; set; }

The ServiceContract and it’s implementation is shown below:

public interface IContact
    Contact[] GetContactList();


public class ContactService : IContact

      #region IContact Members

      public Contact[] GetContactList()
          return new Contact[]
                      new Contact()
                              ContactType ="Friend",Name="John Doe",
                      new Contact()
                              ContactType ="Friend",Name="Robin Crusoe",
                      new Contact()
                              ContactType ="Friend",Name="VanValkenburg",
                       new Contact()
                              ContactType ="Relative",Name="Anthony Price",


So it’s all very simple.. demo.. demo.. with no demons of complexity.One more thing, I have made the endpoint secure with Transport level security.

    <binding name="custombasicHttpBinding">
      <security mode="Transport" >
   <service behaviorConfiguration="DemoServiceApp.ContactService"
    <endpoint address="https://localhost/DemoServiceApp/ContactService.svc"
     binding="basicHttpBinding" bindingConfiguration="custombasicHttpBinding"
      <dns value="localhost" />
    <endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration=""
     contract="IMetadataExchange" />
    <behavior name="DemoServiceApp.ContactService">
     <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"
      httpsGetUrl="https://localhost/DemoServiceApp/ContactService.svc/wsdl" />
     <serviceDebug includeExceptionDetailInFaults="false" />

In my Flex application I want to call this service and display the data in a datagrid.To do so I followed the steps mentioned below (using Flexbuilder)

  • Create the ActionScript Proxy Classes – I used the Flexbuilder option Data -> Import Web Service (WSDL).But I got the following error:


So what’s happening? I have given the URI correct then why is not FlexBuilder able to connect?After checking the log at C:\Documents and Settings\Administrator\My Documents\Flex Builder 3\.metadata I found the following error:

javax.wsdl.WSDLException: WSDLException: faultCode=OTHER_ERROR: Unable to resolve imported document at ‘https://localhost/DemoServiceApp/ContactService.svc?wsdl’.: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

So it’s clear that the SSL handshake is failing and FlexBuilder is not able to locate the certificate.FlexBuilder is based on Eclipse platform which runs on a JVM.For this we need to add the certificate in the certificate store used by JVM under which Flexbuilder is running.The certificate store is the cacerts file present under D:\Program Files\Adobe\Flex Builder 3\jre\lib\security.This is done with keytool command line tool coming with JRE.

So after adding the certificate everything was set, but alas again there was an error Provider com.bea.xml.stream.MXParserFactory not found. After searching about this error message in google I found that it’s a known bug in FlexBuilder


I could not locate the fix and used the hack provided in the site http://poradowski.com/fb/. The root cause seems to be

bug with resolving multiple, recursive <xsd:import> declarations in WSDL that import type schemas

So now after copying the file https://ovh.poradowski.net/com.adobe.flexbuilder.axis2_3.0.214193.jar to D:\Program Files\Adobe\Flex Builder 3\plugins folder everything went fine and set of ActionScript classes got generated.

In the next part of the post we will see what these classes are and how to make the service call.

Kick It on DotNetKicks.com
Tags: ,
  • http://topsy.com/trackback?utm_source=pingback&utm_campaign=L2&url=http://codingndesign.com/blog/%3Fp=133 Tweets that mention Flex with WCF Service Over Https – Part 1 – Coding N Design — Topsy.com

    [...] This post was mentioned on Twitter by Solidsoft, Sankarsan Bose. Sankarsan Bose said: RT @sankarsan Flex with WCF Service Over Https – Part 1 http://bit.ly/bHH7BT [...]