I have been given a wcf service, and i built a local console applicattion to test it, but i keep getting this error shown in the title. My service runs in the browser as it should, showing the screen where it shows the example and the url where you can test it. Probably the error is in the Web.config or in the App.config. I have this two files:
Web.condig
<?xml version="1.0"?>
<configuration>
<appSettings>
...
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.0"/>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true"/>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service name="RAHPEDWCFService.RAHPEDService">
<endpoint address="http://localhost:44184/RAHPEDService.svc" behaviorConfiguration="webHttpBehavior" binding="webHttpBinding" bindingConfiguration="webHttpBindingWithJsonP" contract="RAHPEDWCFService.IRAHPEDService"/>
</service>
</services>
</system.serviceModel>
</configuration>
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IRAHPEDService" 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="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:44184/RAHPEDService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IRAHPEDService"
contract="ServiceReference.IRAHPEDService"
name="BasicHttpBinding_IRAHPEDService" />
</client>
</system.serviceModel>
</configuration>
I hope someone could give me a hint.
Please follow the below steps to resolve it
Please browse your service and click on the Url whether it is showing the metadata or not.
ex:http: //oj:23/Myservice?wsdl
If metadata is not enabled then do the below changes to your service config file.
i. create a mex endpoint
ii. Name the service behavior
Ex:
< serviceBehaviors>
< behavior name="SerBehavior">
< serviceMetadata httpGetEnabled="true"/>
< /behavior>
< /serviceBehaviors>
iii. Add this behavior to your service
Ex:
< service name="RAHPEDWCFService.RAHPEDService" behaviorConfiguration="SerBehavior"> < /service>
iv. Build the service and browse click on url to check the metaData
In your console application right click on the project and click on Add Service Reference
Place the Url in the Address box, click on Go check whether you are able to see the service, select your service and give namespace and click OK
create the object of your ServiceClient
Call your method
able to see the wsdl metadata in the browser.
If you have multiple endpoints in your client configuration file then you have pass the name of the endpoint to the constructor of ServiceCleint Class
Open Visual studio CommandPrompt and type WcfTestClient, right click on MyServiceProjects, add the service and check whether you are able to add or not and once added call your method under the endpoint appears
You should check that you are accessing the correct address. Rather than specify the entire address in the Web.config, more common practice is to provide just a relative address (even
an empty "" is fine), and then you access the service with:
http://servername:[port]/[virtual directory]/RAHPEDWCF.svc/[relative address in Web.config]
E.g. if address in Web.config showed
endpoint address="MySVC"
the full URL for clients (assuming default port 80 and in root of virtual server) might be
http://servername/RAHPEDWCF.svc/MySVC
If you are able to modify Web.config, this is what I would advise.
Related
I am developping a namedpipe Duplex WCF service.
For the basic things, the client and the server are communicating without issue. The server can callback the client sending him strings, and it does it without any issue.
But, when i want it to send a bitmap with byte[] or stream, everything is faulting. Just note i tried to use the stream because the byte[] is not working...
In server side, the byte[]/stream is generated without issue.
But when the server sends the byte[]/stream to the client,if the byte[]/stream is empty it goes through but when it has data it is faulting.
I already checked all my configurations, and tried to set a large buffer/message/poolsize/stringcontent/arraylenght/byteperread/whatever size/lenght because i know that's a classic issue in WCF.
Here is a C/P of the main part of my WCF Config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name="NamedPipeBinding_ICameraService" closeTimeout="00:05:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" maxConnections="10" maxBufferPoolSize="500000000" maxBufferSize="500000000" maxReceivedMessageSize="500000000">
<readerQuotas maxDepth="32" maxStringContentLength="500000000" maxArrayLength="500000000" maxBytesPerRead="500000000" maxNameTableCharCount="500000000"/>
<security mode="Transport"/>
</binding>
</netNamedPipeBinding>
</bindings>
<services>
<service name="EOSDigital.CameraService" behaviorConfiguration="MEX">
<endpoint address="net.pipe://localhost/EOSDigital/CameraService" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding_ICameraService" contract="EOSDigital.ICameraService"/>
<endpoint address="net.pipe://localhost/EOSDigital/CameraService/mex" binding="mexNamedPipeBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MEX">
<serviceMetadata httpGetEnabled="False"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Here is the service callback contract
[ServiceContract]
public interface ICameraServiceCallBack
{
[OperationContract(IsOneWay = true)]
void CallBackFunction(string str);
[OperationContract(IsOneWay = true)]
void LiveviewUpdated(byte[] img);
}
And here is the declaration of my Service contract.
[ServiceContract(CallbackContract = typeof(ICameraServiceCallBack))]
public interface ICameraService
I wont put everything, this is too huge.
This is how i use it
private void CurrentCamera_LiveViewUpdated(object sender, Stream img)
{
MemoryStream data = new MemoryStream();
img.CopyTo(data);
_callback = OperationContext.Current.GetCallbackChannel<ICameraServiceCallBack>();
_callback.CallBackFunction("this is a test"); // ok
_callback.LiveviewUpdated(data.ToArray()); //Faulted
}
I get the Stream from a Canon digital Camera and it is around byte[146242]. When i send a byte[10] it works.
It has to be a problem of size, and I guess i missed something in the config file ...
I also tried to generate and take a look to the scvclog file of my service to see some details of the occurring faulted exception.
But, well... There is not less than 50k characters in one line. This is not readable.
Thank you.
Check your client WCF configuration.
Your client configuration must have the same netNamedPipeBinding as your host.
Put that in your client config file
<netNamedPipeBinding>
<binding name ="duplexEndpoint" closeTimeout="00:05:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="50000000" maxBufferSize="50000000" maxConnections="10" maxReceivedMessageSize="50000000">
<readerQuotas maxDepth="32" maxStringContentLength="50000000" maxArrayLength="50000000" maxBytesPerRead="50000000" maxNameTableCharCount="50000000"/>
</binding>
</netNamedPipeBinding>
This have to be put bellow the serviceModel.Bindings bracket.
Then, bind the configuration in your endpoint bracket
bindingConfiguration="duplexEndpoint"
That should do what you expected.
I m getting the following error when I did set the Windows Authentication enable and anonymous to disabled in IIS.
The authentication schemes configured on the host
('IntegratedWindowsAuthentication') do not allow those configured on
the binding 'BasicHttpBinding' ('Anonymous'). Please ensure that the
SecurityMode is set to Transport or TransportCredentialOnly.
Additionally, this may be resolved by changing the authentication
schemes for this application through the IIS management tool, through
the ServiceHost.Authentication.AuthenticationSchemes property, in the
application configuration file at the
element, by updating the ClientCredentialType property on the
binding, or by adjusting the AuthenticationScheme property on the
HttpTransportBindingElement.
My Wcf Service's web.config is as follows...
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint binding="basicHttpBinding"
bindingConfiguration="BasicHttpEndpointBinding"
contract="Test.IService1" name="BasicHttpEndpoint" />
</client>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceAuthenticationManager
authenticationSchemes="IntegratedWindowsAuthentication"/>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Please advice..
In .Net 4.0+, Simplified WCF configuration uses the 'anonymous' configurations when configurations are not explicitly set on a per-services basis in the <services> section. If you remove the name="BasicHttpEndpointBinding" from the <binding> element, or if you duplicate that <binding> element as a new element with no name attribute, it will become the default, anonymous binding that your WCF services will use. This is often useful in cases where you need to serve as well as consume WCF services that may not all have the same config - but at least you can set a default config for the services that do not have a specific config set. The default/anonymous concept is also applicable to <behavior> elements.
<bindings>
<basicHttpBinding>
<binding> <!--Notice, no name attribute set-->
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
Also, I might add that if your WCF services require authentication, this means that you will either need to consume the service using a real user account, or you will need to grant the the DOMAIN\CLIENTCOMPUTERNAME$ account access to the service - so, perhaps the proper solution for many people may be to alter the configuration to instead allow anonymous access (which is not discussed in my answer). Still, I do sometimes actually elect to secure my WCF services with Windows (Kerberos) authentication.
Adding this worked for me.
<bindings>
<webHttpBinding>
<binding>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</webHttpBinding>
</bindings>
I got this error when updating from .NET 4.0 to .NET 4.5.2. I changed the clientCredentialType from
<security mode="TransportCredentialOnly">
<transport clientCredentialType="None"/>
</security>
to
<security mode="TransportCredentialOnly">
<transport clientCredentialType="InheritedFromHost"/>
</security>
However, setting clientCredentialType="Windows" works equally well.
I had the same issue when consuming already existing WCF web URL.
I tried all the answers mentioned here , but all in all finally only two things helped.
Changing the setting in "Turn windows Features on and off".
Enabling Anonymous authentication along with Windows Authentication in Local IIS server.
<services>
<service name="Test.Service1" behaviorConfiguration="TestName">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpointBinding" contract="Test.IService1" />
</service>
</services>
It solved my problem.
Like the other answers, I needed to update the binding in my Web.config to this:
<basicHttpBinding>
<binding name="basicHttpBindin1">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
But I also needed to update my binding's instantiation:
var binding = new BasicHttpBinding { MaxReceivedMessageSize = 1000000, ReaderQuotas = { MaxDepth = 200 } };
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
I had add a webHttpBinding and point my endpoint to that, which the security settings needed to work. Without that my endpoint used the default WCF config bindings:
<services>
<service behaviorConfiguration="ServiceBehavior" name="Service">
<endpoint address="" binding="webHttpBinding" contract="IService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<webHttpBinding>
<binding>
<!--Notice, no name attribute set-->
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</webHttpBinding>
</bindings>
I'm not entirely sure why, but when I added the 'Factory' attribute to my .SVC file (you need to explicitly drag it to Visual Studio), everything just works - without any changes to default settings in Web.config!
I added Factory="System.ServiceModel.Activation.WebServiceHostFactory" so my .SVC file went from this:
<%# ServiceHost Language="C#" Debug="true" Service="ServiceNameSpace.ServiceName" CodeBehind="ServiceName.svc.cs" %>
to this:
<%# ServiceHost Language="C#" Debug="true" Service="ServiceNameSpace.ServiceName" CodeBehind="ServiceName.svc.cs" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
The only side effect seems to be that when you click on the .SVC file in the browser, you get an 'Endpoint not found' error, but the service works fine when you invoke it correctly anyway. As mentioned previously, I'm using a default Web.config with .NET 4.6 (Simplified WCF configuration), so I may yet need to add endpoint details for that to work again.
I have a self-hosted WCF service which is using the net.tcp protocol for an endpoint and it works fine on a PC with a normal LAN card.
However, I want to support PCs which have dual LAN cards and this gives me problems. I have assigned different IP addresses to the two cards (192.168.1.1 and 193.168.1.1). I then changed my app.config file to try to support the dual LAN by adding a second endpoint for the WCF service, using the second IP address. (My WCF client can handle selecting which of the two endpoint addresses to use.)
When I run the service, I get the following error message:
The ChannelDispatcher at 'net.tcp://193.168.1.1:59301/MyClientService' with contract(s) "'IMyClientService'" is unable to open its IChannelListener.
Additional information from inner exception:
A registration already exists for URI 'net.tcp://193.168.1.1:59301/MyClientService'.
Note: If I change the port # on the second endpoint in the app.config file (e.g. if i use 193.168.1.1:59302), the service starts up fine. That's a workaround, but it would be useful to be able to use the same port for both LANs, if possible.
Oh, and I tried portSharingEnabled on the binding (with the Net.TCP Port Sharing Service running) but that didn't help.
Thanks in advance...
My app.config file looks like this:
<!-- Information about assembly binding and garbage collection -->
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
<system.serviceModel>
<services>
<service name ="MyNamespace.MyClientService" behaviorConfiguration="MyServiceBehavior">
<host>
<baseAddresses>
<!-- Using TCP -->
<add baseAddress = "net.tcp://localhost:59301/MyClientService/" />
</baseAddresses>
</host>
<!-- Using TCP -->
<endpoint
address="net.tcp://192.168.1.1:59301/MyClientService"
binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IMyClientService"
contract="MyNamespace.IMyClientService"
/>
<endpoint
address="net.tcp://193.168.1.1:59301/MyClientService"
binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IMyClientService"
contract="MyNamespace.IMyClientService"
/>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint
address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange"
/>
</service>
</services>
<bindings>
<!-- ==================================================================================== -->
<!-- TCP/IP bindings -->
<netTcpBinding>
<binding name="NetTcpBinding_IMyClientService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="2147483647" maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<!-- <serviceMetadata httpGetEnabled="True"/> -->
<serviceMetadata/>
<!-- 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="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
What does "localhost" resolve to?
Looks like you're adding a base address on "localhost" and two additional endpoints, one of which will probably conflict with localhost.
Try removing the base address, see if that makes a difference...
It looks like the following section is duplicated:
<endpoint
address="net.tcp://192.168.1.1:59301/MyClientService"
binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IMyClientService"
contract="MyNamespace.IMyClientService"
/>
Just try removing one of then
I am learning WCF and right now I am getting one exception while running the application:
Exception:
Could not find default endpoint
element that references contract
'IService1' 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.
Service Code:
namespace StockService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite == null)
{
throw new ArgumentNullException("composite");
}
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}
public string GetCompositedata()
{
CompositeType ct = new CompositeType();
return ct.StringValue;
}
}
}
web.config:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
now using svcutil I have generated proxyclass(generatedProxy.cs) and config file (serviceapp.config) and added it to a console application(client)
Client:
Service1Client sc = new Service1Client();
Console.WriteLine(sc.GetCompositedata());
Console.ReadKey();
config:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" 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="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2614/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
I am not able to figure out why I am getting this exception.
Please help
Is that config you display for the client part of the client app's app.config or web.config, if it's a web site / web application??
You need to include those parts in your application's config - it's not enough to have those config's in a separate file created by svcutil.exe - it needs to be part of your application's configuration.
The svcutil-generated configuration needs to go into your main app.config, not be included as-is.
You need to add an app.config to your project then merge the contents of the svcutil config into the configuration section.
I have problem with streaming. When I send small file like 1kb txt everything is ok, but when I send larger file like 100 kb jpg or 2gb psd I get:
The remote server returned an unexpected response: (400) Bad Request.
I'm using windows 7, VS 2010 and .net 3.5 and WCF Service library
I lost all my weekend on this and I still see this error :/ Please help me
Client:
var client = new WpfApplication1.ServiceReference1.Service1Client("WSHttpBinding_IService1");
client.GetString("test");
string filename = #"d:\test.jpg";
FileStream fs = new FileStream(filename, FileMode.Open);
try
{
client.ProcessStreamFromClient(fs);
}
catch (Exception exception)
{
Console.WriteLine(exception);
}
app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="StreamedHttp" closeTimeout="10:01:00" openTimeout="10:01:00"
receiveTimeout="10:10:00" sendTimeout="10:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536000" maxBufferPoolSize="524288000" maxReceivedMessageSize="65536000"
messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
useDefaultWebProxy="true">
<readerQuotas maxDepth="0" maxStringContentLength="0" maxArrayLength="0"
maxBytesPerRead="0" maxNameTableCharCount="0" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary2/Service1/"
binding="basicHttpBinding" bindingConfiguration="StreamedHttp"
contract="ServiceReference1.IService1" name="WSHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
And Wcf ServiceLibrary:
public void ProcessStreamFromClient(Stream str)
{
//error occuring even this method is empty
using (var outStream = new FileStream(#"e:\test.jpg", FileMode.Create))
{
var buffer = new byte[4096];
int count;
while ((count = str.Read(buffer, 0, buffer.Length)) > 0)
{
outStream.Write(buffer, 0, count);
}
}
}
App.config
<?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>
<bindings>
<basicHttpBinding>
<binding name="Binding1"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536000"
transferMode="Streamed"
bypassProxyOnLocal="false"
closeTimeout="10:01:00"
openTimeout="10:01:00" receiveTimeout="10:10:00" sendTimeout="10:01:00"
maxBufferPoolSize="524288000" maxReceivedMessageSize="65536000" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client />
<services>
<service name="WcfServiceLibrary2.Service1">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary2/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="basicHttpBinding" contract="WcfServiceLibrary2.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</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 -->
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<!-- 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="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Try setting:
<serviceDebug includeExceptionDetailInFaults="true" />
It will not solve the problem, but you may get an error message stating what the problem is.