PrincipalPermission.Demand() failing once WCF Service was moved to SSL - silverlight

My Silverlight/WCF application uses PrincipalPermission in each service method to ensure the user is Authenticated. This works just fine when I have everything configured to HTTP, but once I configured my service endpoints/bindings to support HTTPS (SSL), I get an exception thrown when I call the Demand() method of my PrincipalPermission object.
EDIT: I should mention I am using IIS 7.5 Express to host and debug this project.
Here is the method that checks to make sure the user is authendicated. It's called from each of my service methods:
protected void SecurityCheck(string roleName, bool authenticated)
{
System.ServiceModel.Web.WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;
PrincipalPermission p = new PrincipalPermission(null, roleName, authenticated);
try
{
p.Demand();
}
catch (Exception ex)
{
/* wrap the exception so that Silverlight can consume it */
ServiceException fault = new ServiceException()
{
/* Code = 1 will mean "unauthenticated!" */
Code = 1, Message = ex.Message
};
throw new FaultException<ServiceException>(fault); }
}
}
The execption thown is "Request for principal failed."
Here are the important bits of my web.config file:
<behavior name="BinarySSL">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
<serviceTimeouts transactionTimeout="00:10:00"/>
</behavior>
<binding name="MyApp.Web.Services.ProjectService.customBinding0"
receiveTimeout="00:10:00" sendTimeout="00:10:00">
<binaryMessageEncoding />
<httpsTransport authenticationScheme="Basic"/>
</binding>
<service name="MyApp.Web.Services.ProjectService" behaviorConfiguration="BinarySSL">
<endpoint address="" binding="customBinding" bindingConfiguration="MyApp.Web.Services.ProjectService.customBinding0"
contract="MyApp.Web.Services.ProjectService" />
</service>
Here is the ClientConfig:
<binding name="CustomBinding_ProjectService">
<binaryMessageEncoding />
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
<endpoint address="https://localhost:44300/Services/ProjectService.svc"
binding="customBinding" bindingConfiguration="CustomBinding_ProjectService"
contract="ProjectProxy.ProjectService" name="CustomBinding_ProjectService" />
I'm hoping someone can point in in the right direction here. Again, this configuration works just fine until I configure my services for SSL. Any thoughts?
Thanks,
-Scott
I thought I found the problem, and answered my own question - but I was wrong. Still have the same issue.

Related

Winforms App becomes unresponsive after a period of time when making Asynchronous WCF calls via netTcpBinding

Scenario
I am supporting/enhancing a Windows Form App that communicates via a WCF service hosted in IIS using a ServiceHostFactory class.
For the problem I am trying to solve, I am dealing with these 2 methods in the ServiceContract. The ServiceContract is marked as PerCall.
[OperationContract(IsOneWay = true)]
void RunJob(int jobId);
[OperationContract]
byte[] GetUserJobs(int userID);
The user will submit a job, via the RunJob method in a fire and forget fashion. This job will make a WCF call to another service, get some data back, do a lot of stuff with it and store it in the database. This particular job takes roughly 62 minutes to complete.
While the job is in a Running state, the client calls the GetUserJobs method asynchronously every 10 seconds to check job status and update the GUI accordingly. The client is communicating with the WCF service via netTcpBinding.
Problem
Right around the 1 hour mark, the GUI becomes completely unresponsive. Asynchronous calls are still being made, but the completed event is never being called. It seems to me something is deadlocked or blocking, and I can't figure exactly why this is happening. The GUI can start becoming unresponsive before the RunJob (OneWay) is actually finished on the server, but the job itself always finishes and data gets saved to the database.
So even though the GUI is unusable, the Server is still working, except it won't respond to any WCF calls.
If I edit the web.config on the server to recycle IIS, the GUI becomes responsive again.
I am by no means a WCF expert, and I am really struggling with coming up with a solution to this problem. I am pretty sure it is happening because of the asynchronous calls, but I can't pinpoint the exact cause yet. The Asynchronous calls are getting closed, according to the code below.
According to my trace logs, I see the following errors right around when the GUI becomes unresponsive:
<ExceptionType>System.ServiceModel.CommunicationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>There was an error writing to the pipe: The pipe is being closed. (232, 0xe8).</Message>
Then for Activity http://tempuri.org/IConnectionRegister/ValidateUriRoute I will see:
<DataItem> <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Warning"> <TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.CommunicationObjectFaulted.aspx</TraceIdentifier> <Description>Faulted System.ServiceModel.Channels.ClientFramingDuplexSessionChannel</Description> <AppDomain>/LM/W3SVC/2/ROOT/Service_mt-4-130395564562210673</AppDomain> <Source>System.ServiceModel.Channels.ClientFramingDuplexSessionChannel/56837067</Source> </TraceRecord> </DataItem>
<DataItem> <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Warning"> <TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.CommunicationObjectFaulted.aspx</TraceIdentifier> <Description>Faulted System.ServiceModel.Channels.ServiceChannel</Description> <AppDomain>/LM/W3SVC/2/ROOT/Service_mt-4-130395564562210673</AppDomain> <Source>System.ServiceModel.Channels.ServiceChannel/3537205</Source> </TraceRecord> </DataItem>
Relevant Code/Config (Sanitized a bit)
Client Binding Config
I have tried to set all the timeouts to "infinite" for now, just to rule out that there was some strange timeout behavior. I have tried various timeout settings, but nothing seems to work.
<binding name="MyEndpoint" closeTimeout="infinite"
openTimeout="infinite" receiveTimeout="infinite" sendTimeout="infinite"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxConnections="100" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="infinite"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
Server Binding Config
<netTcpBinding>
<binding name="MyBinding" portSharingEnabled="true" transferMode="Buffered" closeTimeout="infinite" openTimeout="infinite" receiveTimeout="infinite" sendTimeout="infinite" maxBufferPoolSize="524288" maxBufferSize="2147483647" maxConnections="10" listenBacklog="200" maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
<reliableSession ordered="true"
inactivityTimeout="infinite"
enabled="false" />
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
<netTcpBinding>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<ServiceErrorHandler />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
The GUI does something similar to the following to asynchronously call the WCF service:
public void RefreshJobs()
{
//When the GUI becomes unresponsive, a lot of these log statements start piling up in the log file, until service is restarted
Logger.GetInstance().Info("Begin RefreshJobs");
ServiceClient svc = new ServiceClient("MyEndpoint", url);
try
{
svc.GetUserJobsCompleted += new EventHandler<GetUserJobsCompletedEventArgs>(svc_GetJobsCompleted);
}
catch (Exception e)
{
throw e;
}
svc.GetUserJobsAsync(SomeSingleton().CurrentUser.UserID, false, svc);
Logger.GetInstance().Info("End RefreshJobs");
}
private void svc_GetJobsCompleted(object sender, GetUserJobsCompletedEventArgs e)
{
Logger.GetInstance().Info("Start GetJobsCompleted");
if (e.Result != null)
{
//Do Stuff to Update GUI
}
//Close the connection
if (e.UserState is ServiceClient)
{
((ServiceClient)e.UserState).Close();
}
Logger.GetInstance().Info("End GetJobsCompleted");
}
The problem ended up being the CPU being overloaded, which caused the Smsvchost.exe to stop responding.
A fix from Microsoft is available

WCF with Silverlight 4, Publish Subscribe UserName Auth ServiceSecurityContext.Current NULL Reference

I've built a WCF Publish Subscribe Topic Service and can successfully publish/subscribe with a console appplication (meaning I know it at least works in a console), and can successfully add both service references to both in my Silverlight Application.
The Problem:
Every time I try to subscribe or publish (in other words, anytime, I pass through my user name and password) while using Silverlight, the ServiceSecurityContext.Current.PrimaryIdentity is NULL, but it works fine in the console. Also, when accessing the service, it doesn't hit my custom user name and password validator when accessing it from Silverlight, but it does from a console.
What are my requirements?
I need to consume my publish subscribe service via Silverlight. The WCF Service needs to user UserName authentication. The WCF Service needs to be as secure as possible while still allowing for use with Silverlight. I have to use .Net, I have to use WCF PubSubTopic, I have to use Silverlight.
I am open to creating multiple subscriber endpoints(for instance, maybe a custom one for SL to use, and another for my api users), but I need to user the same publisher as the rest of my api users (oh yeah, btw, the WCF service is built as an api for my users to access if they want... I'm only allowing them access to the subscriber, and blocking the publisher)
I'm looking for example, advice, and/or troubleshooting help with my current problem. Here's some of my code
VB.NET code of Silverlight trying to publish something
Private Const PUBLISHER_ENDPOINT_ADDRESS As String = "http://myserver/portal/api/v1/Publisher.svc"
Friend Shared Sub PublishSomething()
Dim binding As PollingDuplexHttpBinding = New PollingDuplexHttpBinding()
Dim endpoint_address As EndpointAddress = New EndpointAddress(PUBLISHER_ENDPOINT_ADDRESS)
Dim client As New PublisherClient(binding, endpoint_address)
client.ClientCredentials.UserName.UserName = String.Format("{0}\{1}", Common.CompanyName, Common.UserName)
client.ClientCredentials.UserName.Password = "mypassword"
Dim uUpdate As New PortalPublisherService.UserUpdatedNotification
uUpdate.CompanyID = CompanyId
uUpdate.CompanyName = CompanyName
uUpdate.isAdvisor = True
uUpdate.isMaster = True
uUpdate.MetaNotes = "Testing from silverlight."
uUpdate.updateById = UserId
uUpdate.updateByName = UserName
uUpdate.userEmail = "bill#domain.com"
uUpdate.userId = UserId
client.UserUpdateAsync(uUpdate)
End Sub
Here's the web.config from the service
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<protocolMapping>
<add scheme="http" binding="wsDualHttpBinding"/>
</protocolMapping>
<extensions>
<bindingExtensions>
<add name="pollingDuplexHttpBinding"
type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,
System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</bindingExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<!--primary behavior-->
<behavior name="Portal.Api.Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceCredentials>
<serviceCertificate findValue="PortalApiCert" storeLocation="LocalMachine" storeName="TrustedPeople" x509FindType="FindBySubjectName"/>
<clientCertificate>
<authentication certificateValidationMode="PeerOrChainTrust" revocationMode="NoCheck"/>
</clientCertificate>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Portal.Web.UserPassAuth, Portal.Web"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<pollingDuplexHttpBinding>
<binding name="pollingBindingConfig"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transferMode="Buffered"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="5242880"
maxBufferSize="655360"
maxReceivedMessageSize="655360">
<readerQuotas maxDepth="32"
maxStringContentLength="81920"
maxArrayLength="163840"
maxBytesPerRead="16384"
maxNameTableCharCount="163840" />
<security mode="TransportCredentialOnly" />
</binding>
</pollingDuplexHttpBinding>
</bindings>
<services>
<!--publisher endpoint configuration settings-->
<service behaviorConfiguration="Portal.Api.Behavior" name="Portal.Web.Publisher">
<endpoint address="" binding="pollingDuplexHttpBinding" contract="Portal.Publisher.IPublisher" bindingConfiguration="pollingBindingConfig"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="meta"/>
<host>
<baseAddresses>
<add baseAddress="http://server/portal/api/v1/IPublisher"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
I want to emphasize that I've tried, figuratively, a million different configurations, but can't remember every combination I've tried. I know I'm doing some stuff in the config I shouldn't be, but I was just trying to get it to work period. Also, here are the links I've looked at already
this one
and this one
there's more, but ... well... it's been a long day...
Thanks in advance for any help
Additional NOTE:
This is the binding I'm successfully using with NON-Silverlight implementations
<wsDualHttpBinding>
<binding name="Portal.Api.Binding" maxReceivedMessageSize="2147483647" sendTimeout="00:10:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="Message">
<message clientCredentialType="UserName" negotiateServiceCredential="false"/>
</security>
</binding>
</wsDualHttpBinding>
Since no one has answered this, I will answer this with my findings. What I'm looking for here is not possible with RIA services and Silverlight over HTTPS. WCF RIA services just don't offer this functionality at this time. If you know this statement not to be true.. please answer my question above with a solution.

WCF MaxReceivedMessageSize will not update when changed in the web.config

I've looked around on the web and none of the solutions to this problem seem to work for me. I have a WCF service being consumed by a Silverlight application. Everything works fine until I attempt to update a large object graph. My trace logs greet me with the lovely error:
The maximum message size quota for incoming messages (65536) has been
exceeded. To increase the quota, use the MaxReceivedMessageSize
property on the appropriate binding element.
I've changed the setting in both my web.config file and in the Silverlight's ClientConfig file and even tried manually creating the proxy and setting the value in code.
My web.config:
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
<endToEndTracing propagateActivity="true" activityTracing="true"
messageFlowTracing="true" />
</diagnostics>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingSettings" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00"
maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="TestConfigService">
<endpoint address="" contract="PreferencesUI.Hub.PreferenceSVC.ITestConfig" binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingSettings" />
</service>
</services>
</system.serviceModel>
My Silverlight:
EndpointAddress ea = new EndpointAddress("http://localhost:37935/TestConfig.svc");
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
binding.CloseTimeout = new TimeSpan(00, 5, 00);
binding.OpenTimeout = new TimeSpan(00, 5, 00);
binding.ReceiveTimeout = new TimeSpan(00, 5, 00);
binding.SendTimeout = new TimeSpan(00, 5, 00);
binding.TextEncoding = System.Text.Encoding.UTF8;
binding.MaxReceivedMessageSize = int.MaxValue;
binding.MaxBufferSize = int.MaxValue;
_preferenceTSTServiceProxy = new TSTC.TestConfigClient(binding, ea);
Does anyone see what I've missed here? Everything I find on the web points out that someone forgot to either set maxReceivedMessageSize or forgot to give the endpoint a bindingConfiguration name value (both of which I've done).
Uggh. I hate this particular aspect of WCF. It's unnecessarily complex to understand, and hard to get right.
I don't claim to understand it all, but I know that there are other places where the "MaxReceivedMessageSize" property can be set, in addition to the binding proper. Also try the underlying transport, like so:
<binding name="CustomBinding_IRoomService">
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
Or like this:
private void AddNetTcpEndpoint()
{
var binaryMessageEncodingTcp = new BinaryMessageEncodingBindingElement
{
MaxSessionSize = ushort.MaxValue
};
binaryMessageEncodingTcp.ReaderQuotas.MaxDepth = ushort.MaxValue;
var tcpDuplexBinding = new CustomBinding(
binaryMessageEncodingTcp,
new TcpTransportBindingElement {MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue}
);
tcpDuplexBinding.SendTimeout = TimeSpan.FromMinutes(2);
tcpDuplexBinding.ReceiveTimeout = TimeSpan.FromMinutes(30);
tcpDuplexBinding.OpenTimeout = TimeSpan.FromSeconds(30);
tcpDuplexBinding.CloseTimeout = TimeSpan.FromSeconds(30);
AddServiceEndpoint(
typeof (IRoomService),
tcpDuplexBinding,
"tcpDuplex").Behaviors.Add(new SilverlightFaultBehavior());
}
}
And there may be other places as well.

The remote server returned an error: NotFound

I have a Silverlight app that consumes a WCF service in my asp.net application.The silverlight app saves "drawings" in the form of ink strokes. These strokes are in the form of xaml (which can be kind of large) of which I am converting to a string and sending to the service to save the string to sql server. (Basically does the same type of thing as this app http://msdn.microsoft.com/en-us/magazine/cc721604.aspx).
This works and I can see my service method is being hit when the drawing is relatively small, but if the drawing gets to big I get this great error and the services method break point never gets hit. It seems that I am passing a size threshold, but I can't figure out if I'm right or what to change to resolve the issue.
I have seached google and SO with no success, so any help would be appreciated. Thanks in advance.
My Service:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class DrawingService: IDrawingService
{
#region IDrawingService Members
public bool SaveEvalAreaDrawing(int EvalAreaId, string xmlToSave)
{
return true;
}
public bool SaveEvalItemDrawing(int EvalItemId, string xmlToSave)
{
return true;
}
public string GetEvalAreaDrawing(int EvalAreaId, string xmlToSave)
{
return "you got the eval drawing!";
}
public string GetEvalItemDrawing(int EvalItemId, string xmlToSave)
{
return "you got the eval item drawing!";
}
#endregion
}
My asp.net app with service web.config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyNameSpace.Services.DrawingServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="customBinding0">
<binaryMessageEncoding />
<httpTransport>
<extendedProtectionPolicy policyEnforcement="Never" />
</httpTransport>
</binding>
</customBinding>
<wsHttpBinding>
<binding name="wsPlainBinding" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None">
<transport clientCredentialType="None">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="None" negotiateServiceCredential="false"
establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service behaviorConfiguration="HSD.ECERS.Services.DrawingServiceBehavior"
name="HSD.ECERS.Services.DrawingService">
<endpoint address="Services" binding="wsHttpBinding" bindingConfiguration="wsPlainBinding"
name="wsPlainHttp" contract="HSD.ECERS.Services.IDrawingService" />
<endpoint address="mex" binding="mexHttpBinding" name="wsdl"
contract="IMetadataExchange" />
</service>
</services>
ServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="wsPlainHttp">
<textMessageEncoding messageVersion="Default" writeEncoding="utf-8" />
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<extendedProtectionPolicy policyEnforcement="Never" />
</httpTransport>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:41594/Services/DrawingService.svc/Services"
binding="customBinding" bindingConfiguration="wsPlainHttp"
contract="EvalDrawingService.IDrawingService" name="wsPlainHttp" />
</client>
</system.serviceModel>
</configuration>
Where VS is showing the error
public bool EndSaveEvalAreaDrawing(System.IAsyncResult result) {
object[] _args = new object[0];
bool _result = ((bool)(base.EndInvoke("SaveEvalAreaDrawing", _args, result))); // Here is where is popping up
return _result;
}
Exception
{System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)
--- End of inner exception stack trace ---
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
--- End of inner exception stack trace ---
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at EvaluaionAncillaryControl.EvalDrawingService.DrawingServiceClient.DrawingServiceClientChannel.EndSaveEvalAreaDrawing(IAsyncResult result)
at EvaluaionAncillaryControl.EvalDrawingService.DrawingServiceClient.EvaluaionAncillaryControl.EvalDrawingService.IDrawingService.EndSaveEvalAreaDrawing(IAsyncResult result)
at EvaluaionAncillaryControl.EvalDrawingService.DrawingServiceClient.OnEndSaveEvalAreaDrawing(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}
Try increasing the readerQuotas -- add this element inside the binding element
<readerQuotas maxStringContentLength="2147483647" />
http://msdn.microsoft.com/en-us/library/ms731325.aspx
Have you tried turning on WCF Tracing? I'm not sure if that works with Silverlight (given that Silverlight has lots of security limitations in terms of the local harddrive), so you might need to set up a simple no silverlight client and reproduce the call with diagnostics turned on.
EDIT: Or, could be the maxArrayLength member of readerQuotas...

Exposing a webHttpBinding WCF service to mobile clients

I have created a very basic service operation that needs to write content to my database. This service looks like the following:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
[ServiceBehavior(IncludeExceptionDetailInFaults = false)]
public class myService : ImyService
{
public MyServiceResult MyMethod(string p1, string p2)
{
try
{
// Do stuff
MyResponseObject r = new MyResponseObject();
r.Property1 = DateTime.Now;
r.Property2 = "Some other data";
return r;
}
catch (Exception ex)
{
return null;
}
}
}
ImyService is defined as shown here:
[ServiceContract]
public interface ImyService
{
[OperationContract]
[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
MyServiceResult MyMethod(string p1, string p2);
}
This service will be exposed to both WP7 and iPhone client applications. Because of this, I believe I need to use webHttpBinding. This has caused me to use the following settings in my web.config file:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="myServiceBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment
aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="myService">
<endpoint address=""
behaviorConfiguration="myServiceBehavior"
binding="webHttpBinding"
contract="ImyService" />
</service>
</services>
</system.serviceModel>
Both the service and WP7 app are part of the same solution. I can successfully add a reference to the service in my application. When I run the application though, the page that references the service throws an error. The error says:
Could not find default endpoint element that references contract 'MyServiceProxy.ImyService' 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 contract could be found in the client element.
What am I doing wrong? It just seems like this should be a pretty straightforward thing. Thank you for your help.
Have you copied the file "ServiceReferences.ClientConfig" into your Windows Phone 7 project? This file is in your WCF project. Also, WP7 clients support basicHttpBinding only. So, you may see an empty "ServiceReferences.ClientConfig" file unless you switch over to basicHttpBinding

Resources