Wednesday, August 15, 2012

WCF Service and Silverlight

WCF Service and Silverlight

I'm new to WCF technology. I have the following situation: one instance of VS contains the WCF class library and client host, the second instance of a Silverlight application. I run a client host and then run Silverlight application, and I get the error: "Could not find endpoint element with name 'WSHttpBinding_IEvalService' and contract 'EmailWCFServiceReference.IEvalService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element."

My code:

<behaviors>   <serviceBehaviors>     <behavior name="MetaData">       <serviceMetadata httpGetEnabled="true"                        httpGetUrl="http://localhost:8080/evals/meta" />     </behavior>   </serviceBehaviors> </behaviors> <services>   <service behaviorConfiguration="MetaData" name="EvalServiceLibrary.EvalService">     <endpoint address="http://127.0.0.1:8080/evals/basic"               binding="basicHttpBinding"               contract="EvalServiceLibrary.IEvalService" />     <endpoint address="http://127.0.0.1:8080/evals/ws"               binding="wsHttpBinding"               contract="EvalServiceLibrary.IEvalService" />     <endpoint address="net.tcp://127.0.0.1:8081/evals"               binding="netTcpBinding"               contract="EvalServiceLibrary.IEvalService"/>     <endpoint address="http://localhost:8080/evals/mex"                binding="mexHttpBinding"               contract="IMetadataExchange" />     <endpoint address="net.tcp://localhost:8081/evals/mex"                binding="mexTcpBinding"               contract="IMetadataExchange" />   </service> </services> 

In Silverlight:

EvalServiceClient channel = new EvalServiceClient("WSHttpBinding_IEvalService"); Eval eval = new Eval(); channel.GetEvalsCompleted += (t, r) => {     if (!r.Cancelled && r.Error == null)         grOdebrane.ItemsSource = r.Result;     else         MessageBox.Show("Nie ma danych"); }; channel.GetEvalsAsync(); 

Ok I change WSHttpBinding_IEvalService to BasicBinding_IEvalService and i have another error: "An error occurred while trying to make a request to URI 'http://127.0.0.1:8080/evals/basic'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details."

Answers & Comments...




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog