I need a example to connect to a wcf webservice from flash

Mar 10, 2010 at 2:16 PM

Hello!!

Using the code example from "AS3 Client for using AMF" discussion, just after using "_netConnection.connect(remotingGateway);" i've used "trace(_netConnection.connected)" and received "false" as a result.

In "var remotingGateway:String  = "http://youradress";" i've changed "youraddres" with "10.0.0.2/Servico/Servico.svc?wsdl", where "10.0.0.2" is the ip where my service is published and "Servico" is the name of the service.

The service is working correctly, returning wsdl ok.

My web.config has:

<system.serviceModel>
    
    <extensions>
      <behaviorExtensions>
        <add name="amfExtensions" type="WcfFlashRemoting.ServiceModel.Configuration.AmfEnablingElement, WcfFlashRemoting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
      </behaviorExtensions>
      <bindingElementExtensions>
        <add name="amfMessageEncoding" type="WcfFlashRemoting.ServiceModel.Configuration.AmfBindingElementExtensionElement, WcfFlashRemoting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
      </bindingElementExtensions>
    </extensions>
    
   <services> 
      <service behaviorConfiguration="WebService.ServicoBehavior" name="WebService.Servico">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BindingConfigServico"
          contract="WebService.IComunicacaoFlash" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <endpoint address="amf" behaviorConfiguration="amfBehave" binding="customBinding" bindingConfiguration="amfBinding" contract="WebService.IComunicacaoFlash"/>
      </service>
    </services>
    
    <bindings>
      <basicHttpBinding>
        <binding name="BindingConfigServico" maxBufferPoolSize="90000000" maxReceivedMessageSize="90000000">
          <readerQuotas maxArrayLength="90000000" maxBytesPerRead="8192"  maxDepth="64"  maxNameTableCharCount="16384"  maxStringContentLength="90000000" />
        </binding>
      </basicHttpBinding>
      
      <customBinding>
        <binding name="amfBinding">
          <amfMessageEncoding />
          <httpTransport manualAddressing="true" />
        </binding>
      </customBinding>

    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WebService.ServicoBehavior">
          <serviceCredentials>
            <serviceCertificate
              findValue="localhost"
              storeLocation="LocalMachine"
              storeName="TrustedPeople"
              x509FindType="FindBySubjectName"/>
            <userNameAuthentication
              userNamePasswordValidationMode="Custom"
              customUserNamePasswordValidatorType="WebService.Seguranca.Autenticacao, WebService"/>
          </serviceCredentials>
          <serviceAuthorization
            principalPermissionMode="Custom"
            serviceAuthorizationManagerType="WebService.Seguranca.GerenciadorAutorizacao, WebService">
            <authorizationPolicies>
              <add policyType="WebService.Seguranca.PoliticaAutorizacao, WebService"/>
            </authorizationPolicies>
          </serviceAuthorization>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      
      <endpointBehaviors>
        <behavior name="xmlBehave">
          <webHttp />
        </behavior>
        <behavior name="amfBehave">
          <amfExtensions />
        </behavior>
      </endpointBehaviors>

    </behaviors>
  </system.serviceModel>

Is there something im doing wrong?

 

Coordinator
Mar 10, 2010 at 3:08 PM

The extension ?wsdl is specifically to get the meta-data for SOAP-based endpoints; Flash Remoting is not SOAP-based and does not need to retrieve meta-data.  Instead, use the endpoint as follows:

http://10.0.0.2/Servico/Servico.svc/amf

This is because your endpoint's address attribute is "amf" - which you could change if you so desired.

 

Good luck with your project!

May 14, 2010 at 3:22 PM

I would like to see this a complete example of code that works to any of these wcf services. For some reason I have written  the example shown inAS3 Client for using AMF but did not make the modifications to my server side configuration file as stated above and received an 2032 error from flex, what we are saying here is that WCF Configuration files much be changed to support Flex Clients.

Thank you for your time and effort