I am frustrated. Okay, here is the error.
There was no endpoint listening at net.pipe://localhost/MyIpcAppToService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
I finally got the App.Config file working, at least no complaints.
Current App.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- 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. -->
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
</startup>
<system.serviceModel>
<services>
<service behaviorConfiguration="MyServiceBehavior" name="MyService.Communication.IpcAppToService">
<endpoint address="net.pipe://localhost/MyIpcAppToService" binding="wsDualHttpBinding" bindingConfiguration="MyAppToServiceEndpointBinding" contract="MyIpc.IIpcAppToService"/>
<endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/MyService/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add scheme="http" binding="wsHttpBinding" bindingConfiguration="MyAppToServiceEndpointBinding" />
</protocolMapping>
<bindings>
<wsDualHttpBinding>
<!-- https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/wcf/wshttpbinding -->
<binding name="MyAppToServiceEndpointBinding"
transactionFlow="true"
sendTimeout="00:01:00"
maxReceivedMessageSize="2147483647"
messageEncoding="Mtom">
</binding>
</wsDualHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://localhost:8733"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
</system.serviceModel>
<appSettings>
<add key="countoffiles" value="7"/>
<add key="logfilelocation" value="abc.txt"/>
</appSettings>
</configuration>
I used to have:
<endpoint address="http://localhost:8733/MyIpcAppToService" ...
and in the Windows Service OnStart() event:
(this following code is now commented out, as of this question post, as the App.config file is supposed to start the named.pipe.)
public Boolean CreatePipeServer()
{
string eventText = $"My Service: CommAppToService::CreatePipeServer(IPC App to Service){Environment.NewLine}";
try
{
if (null != this.ServiceParent.HostIpcAppToService)
this.ServiceParent.HostIpcAppToService = null;
string pipeBaseAddress = #"net.pipe://localhost/MyIpcAppToService";
this.ServiceParent.HostIpcAppToService = new ServiceHost(typeof(IpcAppToService), new Uri(pipeBaseAddress));
NetNamedPipeBinding pipeBinding = new NetNamedPipeBinding()
{
//ReceiveTimeout = new TimeSpan(0, 0, 0, 0, Constants.My_TimeoutMsSendReceive),
//SendTimeout = new TimeSpan(0, 0, 0, 0, Constants.My_TimeoutMsSendReceive),
};
this.ServiceParent.HostIpcAppToService.AddServiceEndpoint(typeof(IIpcAppToService), pipeBinding, "MyIpcAppToService");
this.ServiceParent.HostIpcAppToService.UnknownMessageReceived += HostIpcAppServer_UnknownMessageReceived;
this.ServiceParent.HostIpcAppToService.Faulted += HostIpcAppServer_Faulted;
this.ServiceParent.HostIpcAppToService.Closing += HostIpcAppServer_Closing;
this.ServiceParent.HostIpcAppToService.Closed += HostIpcAppServer_Closed;
this.IpcAppToService = new IpcAppToService();
this.IpcAppToService.ApplyDispatchBehavior(this.ServiceParent.HostIpcAppToService);
this.IpcAppToService.Validate(this.ServiceParent.HostIpcAppToService);
this.ServiceParent.HostIpcAppToService.Open();
return true;
}
I read that the service will AUTOMATICALLY start services placed in the App.Config file, really the MyExeName.exe.config file. I kept looking at the code and saw that it was nearly identical, so I replaced the http:// with net.pipe://.
Sadly, old code, new code, in between code, all nothing. I keep receiving the same error.
I use the following to connect to the service from my desktop application.
public static Boolean ConnectToService()
{
try
{
var callback = new IpcCallbackAppToService();
var context = new InstanceContext(callback);
var pipeFactory = new DuplexChannelFactory<IIpcAppToService>(context, new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/MyIpcAppToService"));
Program.HostIpcAppToService = pipeFactory.CreateChannel();
Program.HostIpcAppToService.Connect();
CommAppToService.IsPipeAppToService = true;
return true;
}
catch (Exception ex)
{
// Log the exception.
Errors.LogException(ex);
}
return false;
}
For whatever it is worth, here is:
Interface
[ServiceContract(SessionMode = SessionMode.Allowed, CallbackContract = typeof(IIpcCallbackAppToService))]
public interface IIpcAppToService
{
[OperationContract(IsOneWay = false)]
[FaultContractAttribute(typeof(IpcAppToServiceFault))]
UInt16 GetServiceId();
...
}
Service:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class IpcAppToService : IIpcAppToService, IErrorHandler
{
public static IIpcCallbackAppToService Callback { get; set; } = null;
public void OpenCallback()
{
IpcAppToService.Callback = OperationContext.Current.GetCallbackChannel<IIpcCallbackAppToService>();
}
public void CloseCallback()
{
IpcAppToService.Callback = null;
}
public void SendMessage(string message)
{
//MessageBox.Show(message);
}
public UInt16 GetServiceId()
{
return Constants.My_Id_AppToService;
}
...
}
Inner Exception from my desktop WinForms Application
(Note, there were no further inner exceptions than this one.):
"The pipe endpoint 'net.pipe://localhost/MyIpcAppToService' could not be found on your local machine."
Why do I keep seeing this error?
UPDATE AFTER 1ST ANSWER
The direction that I would like to take is opposite of the answer, yet the same, namely that the service starts with the App.config and the client uses C# code.
Sadly, I still get the same error.
Revised Server Side App.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- 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. -->
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
</startup>
<system.serviceModel>
<services>
<service behaviorConfiguration="BehaviorMyService" name="MyService.Communication.IpcAppToService">
<endpoint address="net.pipe://localhost/MyIpcAppToService"
binding="netNamedPipeBinding"
bindingConfiguration="EndpointBindingMyAppToService"
contract="MyIpc.IIpcAppToService"
/>
<endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/MyService/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="BehaviorMyService">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true"
httpsGetEnabled="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"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netNamedPipeBinding>
<!-- https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/wcf/wshttpbinding -->
<binding name="EndpointBindingMyAppToService"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transactionFlow="false"
transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288"
maxBufferSize="65536"
maxConnections="10"
maxReceivedMessageSize="2147483647"
>
<security mode="None">
<transport protectionLevel="None" />
</security>
</binding>
</netNamedPipeBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://localhost:8733"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
</system.serviceModel>
<appSettings>
<add key="countoffiles" value="7"/>
<add key="logfilelocation" value="abc.txt"/>
</appSettings>
</configuration>
Revised Client Side C# Code:
var callback = new IpcCallbackAppToService();
InstanceContext context = new InstanceContext(callback);
NetNamedPipeBinding binding = new NetNamedPipeBinding();
binding.Security.Mode = NetNamedPipeSecurityMode.None;
EndpointAddress endpointAddress = new EndpointAddress("net.pipe://localhost/MyIpcAppToService");
var pipeFactory = new DuplexChannelFactory<IIpcAppToService>(context, binding, endpointAddress);
Program.HostIpcAppToService = pipeFactory.CreateChannel();
Program.HostIpcAppToService.Connect();
CommAppToService.IsPipeAppToService = true;
The service throws no exceptions that I can detect, as the EventViewer is clean, just the OnStart() successfully completed message. I know that the system processes the App.config file, as previously when I had errors, the Windows Event Viewer would keep complaining, but not anymore.
Here were some of the Microsoft docs that I used:
netNamedPipeBinding
netNamedPipeBinding2
I did try IO Ninja, but specifying \\.\pipe\MyIpcToService for File Stream, Pipe Listener, and Pipe Monitor, but nothing shows there, even when I try to connect using my WinForms desktop application, which then throws the no pipe listener found exception.
What can be the problem?
<endpoint address="net.pipe://localhost/MyIpcAppToService" binding="wsDualHttpBinding" bindingConfiguration="MyAppToServiceEndpointBinding" contract="MyIpc.IIpcAppToService"/>
Make sure that the service address is in the same form (transport protocol) as the binding type.
TCP(net.tcp://localhost:8000/myservice) NetTcpBinding
IPC(net.pipe://localhost/mypipe) NetNamedPipeBinding
Http/Https(http://localhost:8000/myservice)
Wshttpbinding,Wsdualhttpbinding,basichttpbinding
WebSocket(ws://localhost:3434) Nethttpbinding
MSMQ(net.msmq://localhost/private/myservice) NetMsmqBinding
we are supposed to use NetnamedPipeBinding for the service address. Please refer to my example.
Updated
I have a wcf service using NetNamedPipeBinding hosted in IIS, wish it is useful to you.
Server(wcf service application)
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
}
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}
Web.config(Server side)
<system.serviceModel>
<services>
<service behaviorConfiguration="BehaviorMyService" name="WcfService1.Service1">
<endpoint address="MyIpcAppToService"
binding="netNamedPipeBinding"
bindingConfiguration="EndpointBindingMyAppToService"
contract="WcfService1.IService1"
/>
<endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="BehaviorMyService">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netNamedPipeBinding>
<binding name="EndpointBindingMyAppToService"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transactionFlow="false"
transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288"
maxConnections="10"
maxReceivedMessageSize="2147483647"
>
<security mode="None">
<transport protectionLevel="None" />
</security>
</binding>
</netNamedPipeBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
</system.serviceModel>
Enable WCF new feature.
IIS site(enable net.pipe)
Client(console application)
ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
var result = client.GetData(34);
Console.WriteLine(result);
Client app.config(auto-generated)
I use the http address(service metadata GET address http://localhost:8733/Service1.svc?wsdl) to generated the configuration.
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name="NetNamedPipeBinding_IService1">
<security mode="None" />
</binding>
</netNamedPipeBinding>
</bindings>
<client>
<endpoint address="net.pipe://mynetpipe/Service1.svc/MyIpcAppToService"
binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IService1"
contract="ServiceReference1.IService1" name="NetNamedPipeBinding_IService1" />
</client>
</system.serviceModel>
Feel free to let me know if there is anything I can help with.
Related
I have a WCF SOAP Service with wsHttpBinding, i have 2 methods, the first one executes fine, but for some reason the call to the second method times out. I debuged the method and the everything is fine i my code, it executes and returns, but the in the client, on the same machine, the requests times out. I created a new WCF Service Application project, copied the entire code + config to the new project, ran it, and the method didn't time out for a few times, then suddenly it started doing it again.
here is the config:
<system.serviceModel>
<services>
<service behaviorConfiguration="PolicyServiceBehavior" name="IST.Broker.Services.PolicyServiceV2.PolicyService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="PolicyServiceBindingConfiguration"
contract="IST.Broker.Services.PolicyServiceV2.IPolicyService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:63915/" />
</baseAddresses>
<timeouts closeTimeout="00:01:00" openTimeout="00:01:00" />
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="PolicyServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentSessions="2147483647" maxConcurrentInstances="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="PolicyServiceBindingConfiguration"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2000000"
maxReceivedMessageSize="2000000"
messageEncoding="Text"
textEncoding="utf-8"
useDefaultWebProxy="true"
allowCookies="true">
<readerQuotas
maxDepth="2000000"
maxStringContentLength="2000000"
maxArrayLength="2000000"
maxBytesPerRead="2000000"
maxNameTableCharCount="2000000" />
<reliableSession
enabled="true"
inactivityTimeout="00:01:00" />
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
The service cotnract:
[ServiceContract(SessionMode = SessionMode.Required)]
public interface IPolicyService
{
[OperationContract(IsInitiating = true)]
void Initialize(int employeeId);
[OperationContract(IsInitiating = false, IsTerminating = false)]
GetPolicyResponse GetPolicy(GetPolicyRequest request);
[OperationContract(IsInitiating = false, IsTerminating = false)]
CreateMtplApplicationResponse CreateMtplApplication(CreateMtplApplicationRequest request);
[OperationContract(IsInitiating = false, IsTerminating = true)]
void SignOut();
}
And implementation:
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerSession)]
public class PolicyService : IPolicyService
{
private Employee _currentEmployee;
public GetPolicyResponse GetPolicy(GetPolicyRequest request)
{
return new GetPolicyResponse(PolicyManager.GetPolicy(request.Id, request.PolicyNumber));
}
public void Initialize(int employeeId)
{
if (!InsuranceCompaniesServiceManager.IsInitialized)
{
var appPhysicalPath = HostingEnvironment.ApplicationPhysicalPath;
_currentEmployee = EmployeeManager.GetEmployee(employeeId);
InsuranceCompaniesServiceManager.Initialize(_currentEmployee, appPhysicalPath);
}
}
public CreateMtplApplicationResponse CreateMtplApplication(CreateMtplApplicationRequest request)
{
return new CreateMtplApplicationResponse(PolicyManager.CreateMtplApplication(request.CompanyId, request.Policy.ToBusinessObject(), request.Vehicle.ToBusinessObject(),
request.Clients.Select(x => x.ToBusinessObject()).ToList(), request.GreenCard.ToBusinessObject(), request.Sticker.ToBusinessObject()));
}
public void SignOut()
{
}
}
EDIT:
The method is calling a DLL that inside is calling another service.
Comment out below line because it'll be added automatically while configuring the proxy.
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
If you want to check, Right click on service proxy where you added service proxy, and select "Configure Service Reference" and you'll notice /mex is added in URL of the service at last
Server's App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehaviour">
<serviceMetadata httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="Binding">
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="Server.InternalClass" behaviorConfiguration="NewBehaviour">
<endpoint address="IInternal" binding="wsHttpBinding" bindingConfiguration="Binding" contract="Common.IInternal">
<identity>
<dns value="MyMachine"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="https://MyMachine:8733/"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
Client
static ChannelFactory<IInternal> factory = new ChannelFactory<IInternal>(new WSHttpBinding(), new EndpointAddress("https://MyMachine:8733/IInternal"));
When i call the method factory.CreateChannel(), i get error
I configure certificate
You have to tell the client to use a secure transport channel so that it uses https instead of http. This is true because the binding settings at the client must match the ones at the service side.
You can do this via configuration in the app.config file of the client, or you can do it via code like this:
var ws_http_binding = new WSHttpBinding();
ws_http_binding.Security.Mode = SecurityMode.Transport;
ChannelFactory<IInternal> factory =
new ChannelFactory<IInternal>(
ws_http_binding,
new EndpointAddress("https://MyMachine:8733/IInternal"));
var channel = factory.CreateChannel();
I am trying to setup a NetTCP WCF service.
This is my server code:
iSync.cs:
[ServiceContract]
public interface ISync
{
[OperationContract(IsOneWay = true)]
void UploadMotionDynamic(byte[] jpegStream, string alias, Int16 camIndex, byte[] motionLog, double mul, byte isLive, byte doIsave);
}
Sync.cs:
public class Sync : ISync
{
public void UploadMotionDynamic(byte[] jpegData, string alias, Int16 camIndex, byte[] motionLog,double mul,byte isLive, byte doIsave)
{
//do stuff
}
}
web.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="NetTCPBehaviour">
<serviceDebug includeExceptionDetailInFaults="True" />
<dataContractSerializer maxItemsInObjectGraph="65536" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Sync" behaviorConfiguration="NetTCPBehaviour">
<endpoint address="net.tcp://localhost:8888/Sync" binding="netTcpBinding" contract="ISync" name="wsSyncerMotion" bindingConfiguration="NetTCPBindingEndPoint"/>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="NetTCPBindingEndPoint" sendTimeout="00:01:00">
<security mode="None" />
</binding>
</netTcpBinding>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Now it cannot be the port being blocked because I even tested it by turning off the firewall.
I have made sure 'Net Tcp Listener Adaptor' is running in my
services.
I have added net.tcp in my IIS\Advanced Settings| Enabled
Protocols.
I have added the Non-HTTP activation setting in .NET
Features.
I have followed the links kindly supplied by people here.
The error I get (now) is:
(I cannot seem to enlarge this image with viewing in a different tab)
I am trying to add a reference to a WCF service from my C# Desktop app.
I can add the service reference OK but as soon as I try to open the form within this desktop app I get this error:
NB. I have a UserControl that instantiates a reference to my WCF service and the control in in my GUI Form Class.
Could not find default endpoint element that references contract '' 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.
This is in my app.config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMotionUpdater" messageEncoding="Mtom" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://a url/MotionUpdater.svc/MotionUpdater.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMotionUpdater"
contract="wsCloudFeeder.IMotionUpdater" name="BasicHttpBinding_IMotionUpdater" />
</client>
</system.serviceModel>
</configuration>
And this is in my web.config file:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingEndPoint" maxReceivedMessageSize="10485760" messageEncoding="Mtom" closeTimeout="00:00:10" openTimeout="00:00:10" >
<readerQuotas maxArrayLength="32768"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="MotionUpdater" behaviorConfiguration="ThrottledBehavior">
<endpoint address="MotionUpdater.svc" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingEndPoint" contract="IMotionUpdater"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ThrottledBehavior">
<serviceTimeouts transactionTimeout="1"/>
<serviceThrottling maxConcurrentCalls="64" maxConcurrentInstances="1" maxConcurrentSessions="50"
></serviceThrottling>/>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
If I invoke this reference from a browser window it displays all OK.
It is only where I have a variable in my form class I get the error:
UserControl.Class:
private static wsCloudFeeder.MotionUpdaterClient wsFeeder = new wsCloudFeeder.MotionUpdaterClient();
Server Class:
[ServiceContract]
public interface IMotionUpdater
{
[OperationContract]
void UploadMotion(byte[] jpegStream, string alias, Int16 camIndex);
}
The extra weird thing is that when I run my application it all works no problem.
Also, I have tried just doing this in my control Class but still cannot open up my GUI form..
private static wsCloudFeeder.MotionUpdaterClient wsFeeder = null;
Thanks...
New Error:
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.