Xamarin with WCF integration. WCF service binding error

R3muSGFXR3muSGFX USMember ✭✭
edited March 2017 in Xamarin.Forms

Hello everyone.

I am trying to make a Chat App that can run on multiple platforms. Until now i created the app on WPF to test it and make it stable, for now.
My next step is to make the app run on multiple platforms and I have created the cross platform projects and need to attach my WCF service to them.

I followed this walkthrough https://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/walkthrough_working_with_WCF/ but I have encountered an error when trying to create the proxy web service from Silverlight command. I also configured the following binding configuration https://msdn.microsoft.com/en-us/library/cc197941(v=vs.95).aspx?f=255&MSPPError=-2147217396 but it says this:

L.E.: Here is my Web.Config from the WCF service:

<system.serviceModel>
    <services>
      <service name="CryptoMessenger.WCF.ChatService"
                     behaviorConfiguration="behaviorConfig">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:7968/CryptoChatService.Host/" />
            <!--<add baseAddress="net.tcp://localhost:7967/CryptoChatService.Host/" />-->

          </baseAddresses>
        </host>
        <!--<endpoint address="tcp"
                          binding="netTcpBinding"
                          bindingConfiguration="tcpBinding"
                          contract="CryptoMessenger.WCF.IChat" />-->
        <endpoint address="http"
                  binding="wsDualHttpBinding"
                  bindingConfiguration="httpBinding"
                  contract="CryptoMessenger.WCF.IChat" />
        <!--<endpoint address="net.tcp://localhost:7966/CryptoChatService.Host/mex"
                          binding="mexTcpBinding"
                          contract="IMetadataExchange" />-->
        <endpoint address="http://localhost:7968/CryptoChatService.Host/mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
    <client>
      <endpoint address="http://localhost:7965/ChatService.svc"
                binding="customBinding"
                bindingConfiguration="SVCBindingConfiguration"
                contract="CryptoMessenger.WCF.IChat"
                name="SVCBindings"/>
    </client>
    <behaviors>
      <serviceBehaviors>
        <behavior name="behaviorConfig">
          <serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <customBinding>
        <binding name="SVCBindingConfiguration">
          <httpTransport
            maxReceivedMessageSize="67108864" 
                      maxBufferSize="67108864" />
        </binding>
      </customBinding>
      <wsDualHttpBinding>
        <binding name="httpBinding"
                             maxReceivedMessageSize="67108864"
                             maxBufferPoolSize="67108864"
                             closeTimeout="00:00:10"
                             openTimeout="00:00:10"
                             receiveTimeout="00:20:00"
                             sendTimeout="00:01:00"
                 transactionFlow="true">
          <security mode="None">
          </security>
          <readerQuotas maxArrayLength="67108864"
                                  maxBytesPerRead="67108864"
                                  maxStringContentLength="67108864" />
        </binding>
      </wsDualHttpBinding>
      <netTcpBinding>
        <binding name="tcpBinding"
                         maxBufferSize="67108864"
                         maxReceivedMessageSize="67108864"
                         maxBufferPoolSize="67108864"
                         transferMode="Buffered"
                         closeTimeout="00:00:10"
                         openTimeout="00:00:10"
                         receiveTimeout="00:20:00"
                         sendTimeout="00:01:00"
                         maxConnections="100">
          <security mode="None">
          </security>
          <readerQuotas maxArrayLength="67108864"
                                  maxBytesPerRead="67108864"
                                  maxStringContentLength="67108864"/>
          <reliableSession enabled="true" inactivityTimeout="00:20:00"/>
        </binding>
      </netTcpBinding>
    </bindings>

    <protocolMapping>
        <add binding="wsDualHttpBinding" scheme="http" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
  </system.serviceModel>

I would really apreciate it if somebody could help me solve this, because I have a little udnerstanding about this binding configurations...

Thanks in advance.

Tagged:

Answers

  • SirAndriySirAndriy USMember ✭✭✭
    edited March 2017

    Try turn off firewall

    if you look into Silverlight command error, you will see "Unable to connect to the remote server"

  • R3muSGFXR3muSGFX USMember ✭✭

    @SirAndriy said:
    Try turn off firewall

    if you look into Silverlight command error, you will see "Unable to connect to the remote server"

    I don't have the firewall active, but still I added a firewall rule with all the ports of my WCF service...

  • SirAndriySirAndriy USMember ✭✭✭

    You service is only on localhost? Try open you web service in device browser, I aspect it will be unavailable too. It's because your localhost is enable only in your PC.

    Try to googled "How to test localhost from any device on your network"

  • R3muSGFXR3muSGFX USMember ✭✭

    After some time spent working with the error and going over the walkthrough, over and over again I finally came up with the solution for this. I forgot to specify the httpGetUrl:

    <serviceMetadata httpGetEnabled="true" httpGetUrl=""/>

    Finally I've compiled the reference file.

    Thank you @SirAndriy for your help :smile: !

  • SirAndriySirAndriy USMember ✭✭✭

    you welcome

  • ZekiriZekiri Member

    Hi in my chanel youtub : Soft.Web (Connect to a WCF from Xamarin.Forms)

Sign In or Register to comment.