How do I configure my Silverlight app and duplex WFC service to use HTTPS? Currently evrything works if using HTTP, but as soon as the client hits the site using HTTPS, the callback creation within the service fails. I believe I need to modify my config file, but I can't figure out what it should be set to.
Here is my current config:
<system.serviceModel>
<extensions>
<bindingExtensions>
<add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,
System.ServiceModel.PollingDuplex,
Version=4.0.0.0,
Culture=neutral,
PublicKeyToken=31bf3856ad364e35"/>
</bindingExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceThrottling maxConcurrentSessions="2147483647" maxConcurrentInstances="2147483647" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<pollingDuplex>
<binding name="myPollingDuplex" duplexMode="SingleMessagePerPoll" />
</pollingDuplex>
</bindings>
<services>
<service name="UnityEca.Web.Services.SearchPollingService">
<endpoint address="" binding="pollingDuplex" bindingConfiguration="myPollingDuplex" contract="UnityEca.Web.Services.SearchPollingService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
From my Silverlight app, I create the client proxy like so:
SearchPollingServiceClient client = new SearchPollingProxy.SearchPollingServiceClient(
new PollingDuplexHttpBinding { DuplexMode = PollingDuplexMode.SingleMessagePerPoll },
new EndpointAddress("../Services/SearchPollingService.svc"));
Thanks...
Have you implemented a clientaccesspolicy file for SSL? See here: http://timheuer.com/blog/archive/2008/10/14/calling-secure-services-with-silverlight-2-ssl-https.aspx
You may also need to add a security element to your ServicesReferences.clientconfig file:
<bindings>
<pollingDuplex>
<binding name="myPollingDuplex" duplexMode="SingleMessagePerPoll">
<security mode="Transport" />
</binding>
</pollingDuplex>
</bindings>
See this question for more details.
Related
We've deployed a WPF application (.NET 4) to a corporate network. The application doesn't have direct access to the database. The application talks to the database using a WCF service. When the customer tries to login to the application he gets an error
There was no endpoint listening at
http://oururl/dataportal/wcfportal.svc that could accept the message.
This is often caused by an incorrect address or SOAP action. See inner
exception, if present, for more details.
But if the customer tries to login while Fiddler is running in the background, then it all works fine. See the app.config file below. Any help to diagnose the issue will be appreciated.
<configuration>
<system.serviceModel>
<!-- ZIP Enabled Dataportal -->
<extensions>
<bindingElementExtensions>
<add name="gzipMessageEncoding"
type="Microsoft.ServiceModel.Samples.GZipMessageEncodingElement, GZipEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bindingElementExtensions>
</extensions>
<client>
<endpoint name="WcfDataPortal"
address="http://oururl/dataportal/wcfportal.svc"
binding="customBinding"
bindingConfiguration="dataportalCompressed"
contract="Csla.Server.Hosts.IWcfPortal" />
<metadata>
<policyImporters>
<extension type="Microsoft.ServiceModel.Samples.GZipMessageEncodingBindingElementImporter, GZipEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</policyImporters>
</metadata>
</client>
<bindings>
<customBinding>
<binding name="dataportalCompressed">
<gzipMessageEncoding innerMessageEncoding="textMessageEncoding"/>
<httpTransport hostNameComparisonMode="StrongWildcard"
manualAddressing="False" maxReceivedMessageSize="6553600"
authenticationScheme="Anonymous" bypassProxyOnLocal="False"
realm="" useDefaultWebProxy="True" />
</binding>
</customBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="SSL_ServiceBehavior">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
First check that are you able to access the SVC file from browser. There may be proxy issue.
I have designed the WCF service with operation contracts that can store data in a SQL server database. The operation contract takes parameters such as dataID, dataDescrip., dataType and (byte array) data content. The byte array is originally a file that has to be stored in the database.
I used the WCF service within a web form client application (where the WCF service is referenced) to send the data, but when I send the file >40 kb as a byte array with other parameters it returns bad request 400 error. When I send files less than 30KB or so, the data is successfully stored in DB, no error is returned.
I believe this has to do with large data streaming and changing the size to larger numbers in web.config. I have tried to change the size in the client application web config, but no luck. Also changing the encoding tag to MTOM that returns mismatch client and service binding. I'm using wsHttpBinding.
Not sure what the problem is.
I have read: http://msdn.microsoft.com/en-us/library/ms733742.aspx
but how can I change my current wcf service to enable that while still storing the data to database?
My server config file, App.config from service library is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="IncidentServiceLibrary.IncDataService">
<endpoint address="" binding="wsHttpBinding" contract="IncidentServiceLibrary.IIncDataService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/IncidentServiceLibrary/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<connectionStrings>
.....
</connectionStrings>
</configuration>
The client config file, Web.config in the client I call my service from:
...
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IIncDataService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/Design_Time_Addresses/IncidentServiceLibrary/Service1/" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IIncDataService" contract="IncServiceReference1.IIncDataService" name="WSHttpBinding_IIncDataService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" /></system.serviceModel>
</configuration>
I have an silverlight application with an SSL service. If i deploy the service without SSL all works right, but if i activate the SSL and change the endpoint from http://MyService to https://MyService in the servicereference.clientconfig, and change in web.config:
endpoint from "basicHttpBinding" to "webHttpBinding"
The service dont work and produce the next error:
Unhandled error in silverlight Application [Arg_NullReferenceException]
Arguments: debbuging resource string ar unavalible
I dont know if something is wrong or i need to do something more... etc.
Thanks in advance to everybody i need help.
You can't convert the service endpoint to webHttpBinding because Silverlight only supports basicHttpBinding. To secure your services for Silverlight, you need create a basicHttpBinding with Transport level security. Then, create a service behavior that specifies that httpsGetEnabled="true". I have included a sample below:
Service Side Web.config
<bindings>
<basicHttpBinding>
<binding name="SecureBasicHttpBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="MyService" behaviorConfiguration="SecureServiceBehavior">
<endpoint address="" binding="basicHttpBinding" contract="IMyService" bindingConfiguration="SecureBasicHttpBinding" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SecureServiceBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
Client Side
In the client config, add the same SecureBasicHttpBinding from the services and then add the following endpoint attribute:
bindingConfiguration="SecureBasicHttpBinding"
I have a silverlight app that talks to a WCF service inside of an ASP.NET website. The following code works:
var service = new ChannelFactory<IService>(new BasicHttpBinding()
{
MaxReceivedMessageSize = int.MaxValue
},
new EndpointAddress(Settings.ServiceUrl)).CreateChannel();
But I really want to take advantage of "binary encoding". To run the service with binary encoding, you cannot use the BasicHttpBinding, you need to use a CustomBinding! The following code is used in the same place, but yields an HTTP 415 Unsupported media type status from the web server. In a debugging session, no breakpoints are reached on the server.
var service = new ChannelFactory<IService>(new CustomBinding(new BinaryMessageEncodingBindingElement(), new HttpTransportBindingElement()
{
MaxReceivedMessageSize = int.MaxValue
}),
new EndpointAddress(Settings.ServiceUrl)).CreateChannel();
I need help finding out why this setting doesnt work! BTW here is the service section in my web config on the server side:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="myBinding">
<binaryMessageEncoding />
<httpTransport authenticationScheme="Negotiate"/>
</binding>
</customBinding>
</bindings>
<services>
<service name="myService">
<endpoint address="" binding="customBinding" bindingConfiguration="myBinding" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="wcfServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
I figured out how to enable BinaryMessageEncoding, and I can confirm BinaryMessageEncoding works correctly in IIS and visual studio web dev debug server.
The problem was the all-too-common WCF configuration problem. My "service name" was an arbitrary name, but it SHOULD have been the fully qualified name of the service class. Instead of throwing an exception, WCF was exposing the service under some default behavior, and not warning me that the configuration was not valid.
<bindings>
<customBinding>
<binding name="myBinding" >
<binaryMessageEncoding >
<!--readerQuotas are used to set upper limits on message payload-->
<readerQuotas
maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"
/>
</binaryMessageEncoding>
<httpTransport authenticationScheme="Ntlm" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"/>
</binding>
</customBinding>
</bindings>
<services>
<!--the service name must be the fully-qualified name of the service class-->
<service name="MyProgram.DataService">
<!--this line allows metatada exchange-->
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<endpoint address="" binding="customBinding" bindingConfiguration="myBinding" contract="MyProgram.IDataService" />
</service>
</services>
I don't understand all Silverlight capabilities but at the moment I think your service doesn't work at all. Your custom binding does not have any transport binding element which is mandatory.
Try to change your binding:
<bindings>
<customBinding>
<binding name="myBinding">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
I am trying to host a WCF service using IIS, (works fine in Cassini). However when I host it in IIS I get the following error:
"A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)"
I thought this might be due to IIS and windows authentication, so I changed the connectionstring to directly login to the database with a uid and password, makes no difference. I don't think I am getting that far, as I would expect a sql security error if that were the case.
I have set up a brand new server (2008), and still I get the same issues...
What setting to I need to implement to get this going?
Example WCF Code
private GenericDataClassesDataContext _db = new GenericDataClassesDataContext();
public ReferenceValue[] GetReferenceValues()
{
try
{
return _db.ReferenceValues.ToArray();
}
catch (Exception e)
{
throw new FaultException(e.Message);
}
}
Web.Config
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings>
<!--<add name="TtasConnectionString" connectionString="Data Source=stdev07;Initial Catalog=Ttas;;uid=srvTtas;pwd=pa$$w0rd;MultipleActiveResultSets=True" providerName="System.Data.SqlClient"/>-->
<add name="TTASConnectionString" connectionString="Data Source=STDEV07;Initial Catalog=IRF;Integrated Security=SSPI" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
</compilation>
<authentication mode="Windows"/>
<identity impersonate="true"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="silverlightFaults" type="Moe.Tactical.GenericData.Wcf.SilverlightFaultBehavior, Moe.Tactical.GenericData.Wcf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<behaviors>
<endpointBehaviors>
<behavior name="SilverlightFaultBehavior">
<silverlightFaults />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Moe.Tactical.GenericData.Wcf.GenericDataServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<!--<serviceDebug includeExceptionDetailInFaults="false" />-->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="winAuthBasicHttpBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="Moe.Tactical.GenericData.Wcf.GenericDataServiceBehavior" name="Moe.Tactical.GenericData.Wcf.GenericDataService">
<!--bindingConfiguration="winAuthBasicHttpBinding" [in gap]-->
<endpoint address=""
binding="basicHttpBinding"
behaviorConfiguration="SilverlightFaultBehavior"
contract="Moe.Tactical.GenericData.Wcf.IGenericDataService">
<identity>
<dns value="localhost:3637"/>
</identity>
</endpoint>
<!--<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>-->
</service>
</services>
</system.serviceModel>
</configuration>
I think the reason is in the following line of web.config:
<identity impersonate="true"/>
You should change it to
<identity impersonate="false"/>