2016-06-09 2 views
0

dll (xmlsoccer) 구현을 위해 app.config 파일에 일부 태그를 추가해야합니다. 나는 구성 노드에서app.config Xamarin pcl

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 

같은 것을 추가해야하지만 어디 있는지 모르겠어. 가 나는 app.config 파일을 만들려고하고 구성표로 DotNetConfig.xsd을 설정할 수 있지만 컴파일하는 동안, 나는이 오류가 :

  • 경고 : *
  • SyStem.InvalidOperationException에 대한 엔드 포인트 구성을로드하는 데 실패합니다 : A ~ 이 채널 공장에 바인딩을 구성해야합니다.

아무도 도와 줄 수 있습니까?

`공용 클래스 MainActivity :

나는이 작성하는 노력 (" http://www.xmlsoccer.com/FootballDataDemo.asmx")를 FormsApplicationActivity { 공공 정적 읽기 전용 EndpointAddress를를 EndPoint = 새 EndpointAddress를을;

App application; 
    protected override void OnCreate(Bundle bundle) 
    { 
     base.OnCreate(bundle); 
     global::Xamarin.Forms.Forms.Init(this, bundle);   
     // LoadApplication(new App(binding, EndPoint)); 
     CreateBasicHttp(); 
     LoadApplication(application); 
    } 

    private void CreateBasicHttp() 
    { 
     var binding = new BasicHttpBinding() 
     { 
      Name = "basicHttpBinding", 
      MaxReceivedMessageSize = 1000000, 
     }; 
     binding.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas() 
     { 
      MaxArrayLength = 2147483646, 
      MaxStringContentLength = 5242880, 
     }; 
     var timeout = new TimeSpan(0, 1, 0); 
     binding.SendTimeout = timeout; 
     binding.OpenTimeout = timeout; 
     binding.ReceiveTimeout = timeout;  
     application = new App(binding, new EndpointAddress("http://www.xmlsoccer.com/FootballDataDemo.asmx")); 
    }` 

내 MainActivity.cs에 있지만 분명히 충분하지 않습니다.

+0

자 마린 모바일 응용 프로그램이 파일을 app.config에 사용하지 않는 서비스에 액세스하려면 다음 코드를 추가

3 .-. – Jason

+0

완벽 -_- 그래서 문제를 해결하기 위해 내가 할 수있는 것에 대한 제안은 무엇입니까? – LauraC

+0

게시 한 내용에서 app.config에서 실제로 수행해야 할 작업을 알 수 없습니다. 프로그래밍 방식으로 수행 할 수있는 WCF 서비스의 바인딩 일뿐입니다. – Jason

답변

-1

아직도 답변을 찾으십니까? 여기를보세요 : https://forums.xamarin.com/discussion/19303/how-to-consume-wcf-service-in-xamarin-forms-pcl

단계 :

1 .- Windows에서 명령 프롬프트를 열고 WSDL 파일에서 프록시 생성에 실버 라이트 SDK에서 SLSvcUtil.exe 도구 를 사용하여. slsvcutil http://www.yourserver.com/WebServices/YourServiceSoapClient.asmx?WSDL/out : YourService.cs 해당 유틸리티는 내 컴퓨터의 C : \ Program Files \ Microsoft SDKs \ Silverlight \ v5.0 \ Tools \에 있습니다.

2. 결과로 생성 된 YourService.cs 파일을 프로젝트에 추가합니다.

// Create the WCF client (created using SLSvcUtil.exe on Windows) 
    YourServiceSoapClient client = new YourServiceSoapClient(
     new BasicHttpBinding(), 
     new EndpointAddress("hhttp://www.yourserver.com/WebServices/YourServiceSoapClient.asmx")); 

    // Call the proxy - this should use the async versions 
    client.ServiceFunctionCompleted += OnGotResult; 
    client.ServiceFunctionAsync(parameter); 

그리고 OnGotResult 기능 :

void OnGotResult(object sender, ServiceFunctionCompletedEventArgs e) 
{ 
    Device.BeginInvokeOnMainThread(async() => { 
     string error = null; 
     if (e.Error != null) 
      error = e.Error.Message; 
     else if (e.Cancelled) 
      error = "Cancelled"; 

     if (!string.IsNullOrEmpty(error)) 
     { 
      await DisplayAlert("Error", error, "OK", "Cancel"); 
     } 
     else 
     { 
      resultsLabel.Text = e.Result; 
     } 
    }); 
} 
+1

이 링크는 질문에 대답 할 수 있지만 답변의 핵심 부분을 여기에 포함시키고 참조 용 링크를 제공하는 것이 좋습니다. 링크 된 페이지가 변경되면 링크 전용 답변이 유효하지 않게 될 수 있습니다. - [검토 중] (리뷰/낮은 품질의 게시물/13587930) – RamenChef

+0

코드를 추가했습니다. 지금 개선 되었습니까? – Mulflar

관련 문제