2013-05-15 5 views
0

WCF 서비스 및 Windows Phone 연결에 문제가 있습니다. 소스 코드가없는 서비스가 있습니다 (웹에서만 게시). Windows Phone 7 App에서 사용해야합니다.Windows Phone 7의 WCF 서비스

나는 프로젝트에 서비스 참조, VS 날 ServiceReferences.ClientConfig 파일 생성 추가

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="HttpBinding_IWcfMobilServices"> 
      <security mode="None" /> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://www.www.com/WcfMobilServices.svc" 
      binding="basicHttpBinding" bindingConfiguration="HttpBinding_IWcfMobilServices" 
      contract="MobileService.IWcfMobilServices" name="HttpBinding_IWcfMobilServices"></endpoint> 
    </client> 
    </system.serviceModel> 
</configuration> 

내가 서비스 메소드를 호출

는 : LoginCompleted에

public static void Login() 
{ 
    var proxy = new MobileService.WcfMobilServicesClient(); 
    proxy.LoginAsync("loginName", "paswword"); 
    proxy.LoginCompleted += (s, a) => 
     { 
       //some code 
     }; 
} 

응용 프로그램은에 나에게 예외를 throw합니다. 결과 :

System.ServiceModel.ProtocolException: Content Type text/xml; charset=utf-8 was not supported by service http://www.www.com/WcfMobilServices.svc . The client and service bindings may be mismatched. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.ClientHttpWebRequest.<>c_DisplayClasse.b_d(Object sendState) at System.Net.Browser.AsyncHelper.<>c_DisplayClass1.b_0(Object sendState) --- End of inner exception stack trace --- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) --- End of inner exception stack trace --- at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() at W7App.MobileService.LoginCompletedEventArgs.get_Result()} System.ServiceModel.CommunicationException {System.ServiceModel.ProtocolException}

어떤 생각이 잘못된가요?

내가있는 wsHttpBinding에 설정 파일의 바인딩을 변경하려고했으나 VS 나에게 경고를 보여줍니다

The element 'bindings' has invalid child element 'wsHttpBinding'. List of Possible elements expected: 'basicHttpBinding, CustomBinding'.

덕분에 우리의 대화에 이어

+0

경고가 계속되면 어떻게됩니까? 이것은 가능한 복제 일 수 있습니다 : http://stackoverflow.com/questions/8250251/wcf-content-type-text-xml-charset-utf-8-was-not-supported-by-service – cvraman

+0

경고를 무시하면 구성에서 응용 프로그램이 wcf 클래스의 인스턴스를 만드는 동안 오류가 발생했습니다 : 서비스 참조 구성에서 인식 할 수없는 요소 'wsHttpBinding'. Silverlight에서는 Windows Communication Foundation 구성 기능의 하위 집합 만 사용할 수 있습니다. – Davecz

+1

Silverlight/WP7은 불행히도 기본 HTTP 만 지원합니다. 연결하려고하는 엔드 포인트가 기본 HTTP 바인딩을 지원하는지 알고 있습니까? 그것은 그렇지 않을 수도 있습니다? – Belogix

답변

2

합니다. Silverlight/Windows Phone 7 basicHttpBindingCustomBinding을 지원합니다. 콘솔 응용 프로그램을 만들면 wsHttpBinding을 사용하여 연결할 수있었습니다. 따라서 옵션은 다음과 같습니다.

  1. basicHttpBinding을 종점에 추가하도록 요청하십시오.
  2. Windows Phone과 다른 WCF 서비스 사이에있는 다른 WCF 서비스를 만듭니다. 그런 다음 basicHttpBinding에 연결할 수 있으며 중간 WCF는 wsHttpBinding을 사용하여 다른 서비스에 연결할 수 있습니다.

분명히 옵션 2는 느려지고 모든 업데이트에 번거롭고 번거롭지 만 옵션 1이 가능하지 않으면 나는 다른 선택 사항이 많지 않다고 생각합니다.