locked
Windows Phone 8 connecting to a secure web service RRS feed

  • Question

  • I have created a local web service and hosted it in IIS with an X509 certificate. When i connect to the service using the WCF Text tool it returns an error if the username/password is not supplied which is correct so far (i think anyway)

    Here the Config (ive removed areas which i think are not required for my question)

          <service behaviorConfiguration="NewBehavior0" name="TechnologyService">
            <endpoint address="mex" binding="mexHttpBinding" contract="ITechnology" />
           <endpoint address="Service.svc" binding="wsHttpBinding" bindingConfiguration="NewBinding0" contract="ITechnology" />
          </service>
        </services>
        <bindings>
          <wsHttpBinding>
            <binding name="NewBinding0">
              <security>
                <message clientCredentialType="UserName" />
              </security>
            </binding>
          </wsHttpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior name="NewBehavior0">
              <serviceCredentials>
                <clientCertificate>
                  <authentication certificateValidationMode="PeerTrust" />
                </clientCertificate>
                <serviceCertificate findValue="Server" storeLocation="LocalMachine"
                  storeName="TrustedPeople" x509FindType="FindBySubjectName" />
                <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="TechnologyService, Services"/>
              </serviceCredentials>
              <serviceMetadata httpGetEnabled="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <directoryBrowse enabled="true" />
      </system.webServer>
    </configuration>

    I can connect to the above service from IE and see the WSDL file.

    Now i try and connect to the service from a Windows Phone 8 emulator. The WP8 config (ServiceReferences.ClientConfig) has the following 

    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_ITechnology" maxBufferSize="2147483647"
                        maxReceivedMessageSize="2147483647">
                        <security mode="None" />
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost/myService.svc"
                    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITechnology"
                    contract="ITechnology" name="WcfSer" />
            </client>
        </system.serviceModel>
    </configuration>

    but continue to receive the error "The remote server returned an error: NotFound" So i changed the element on the Phone config

    binding="basicHttpBinding"

    to wsHttpBinding but then got the error "Binding type wsHttpBinding instance wsHttpBinding not found in config." 

    So tried to add a custom binding but think im making this difficult than it is..... Could anyone advise how to go about this?

    Thanks


    • Edited by Pure Deal Saturday, October 19, 2013 11:36 AM
    Saturday, October 19, 2013 11:35 AM

All replies

  • This seems more like a WCF question than a phone question, but Prashant will be able to tell us what's going on. I'll ask him to chime in.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, October 21, 2013 12:33 PM
  • Hi PD,

    Can you hit the server from the Phone Emulator IE and get the WSLD file too?

    This error: The remote server returned an error: NotFound

    Means that whatever you are looking for is not found on the server.  You can use Fiddler to compare the HTTPS/HTTP traffic from a successful case (say a desktop application) and the failed case (your phone app).

    Configure the Windows Phone 8 Emulator to work with Fiddler


    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Monday, October 21, 2013 12:42 PM
  • I have created a local web service and hosted it in IIS with an X509 certificate.


    The certificates subject needs to match the host name of the Uri used to access the server.

    Also, if you're using a self-signed test certificate you will need to manually install that certificate on the phone or emulator you are using to test your application. 

    I also note that your endpoint address is using 'localhost' as the host name... this will not work on Windows Phone 8 emulator... see: How to connect to a local web service from the Windows Phone 8 emulator.


    -Eric.

    Monday, October 21, 2013 5:18 PM