Wcf in Medium / Partial Trust (Mosso) - odd problem / config error - wcf

Whew! Ok… I solved my Wcf / Linq errors (and learned a lot – a series of blog posts will follow next weak). Now I need to deploy. We run on the Mosso / Rackspace cloud, and for the moment that environment runs in a partial trust environment.
To make it simple, I added a method to my Wcf service that does just about NOTHING.
public string Echo(string what)
{
return what;
}
I built it all, and shipped it to the test server with the following Web.Config (relevant section only)… yes, I will need to add security obviously before exposing the dangerous methods, but for now I jsut want the anonymous stuff running :)
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicAnonymous">
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="FooBar.Backend.Web.Services.CoreDataWcfServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="FooBar.Backend.Web.Services.CoreDataWcfServiceBehavior"
name="FooBar.Backend.Web.Services.CoreDataWcfService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicAnonymous" contract="FooBar.Backend.Web.Services.ICoreDataWcfService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://backend.FooBar.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
</system.serviceModel>
So, off I go to call it in the simplest way I can with a console application. i add the service reference and it adds fine. Then I call it (I took inactive code for brevity)…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreWcfHarness.CoreDataServiceReference;
namespace CoreWcfHarness
{
class Program
{
static void Main(string[] args)
{
var context = new CoreDataWcfServiceClient();
var echoval = context.Echo("Hello World!");
Console.WriteLine(String.Format("{0}\n", echoval));
Console.ReadKey();
}
}
}
And blammo. I get hit with an exception.
System.ServiceModel.FaultException`1 was unhandled
Message="Request failed."
Source="mscorlib"
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at CoreWcfHarness.CoreDataServiceReference.ICoreDataWcfService.Echo(String what)
at CoreWcfHarness.CoreDataServiceReference.CoreDataWcfServiceClient.Echo(String what) in C:\PathToProject\corewcfharness\service references\coredataservicereference\reference.cs:line 1890
at CoreWcfHarness.Program.Main(String[] args) in C:\PathToProject\CoreWcfHarness\Program.cs:line 42
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
This is about as simple as it gets. Anyone familiar with medium trust environments and / or good with a stack trace?
Thanks!

"Request Failed" could be a number of things.
It looks like the most probable reason is that the request is not reaching the server. You should check the server logs to make sure that the request is being sent to the correct place.

Related

"No destination configuration registered" - WCF/SAP integration using SAP nCo3 (SAP .NET Connectior 3.0)

When I try to call a WCF service I developed I get this error message: "Method or operation is not implemented".
Let me explain the scenario I'm facing and them I'll give you more details, the code and etc:
I'm developing a WCf service in .NET framework 4.0 in a Windows 8/Visual Studio 2012 machine.
The WCF service will be accessed from a mobile application developed in .NET compact framework 2.0 (Dev environment: a Virtual Machine running Windows XP service pack 3, Visual Studio 2008, Windows Mobile 6.1 Professional Emulator).
The WCF service is using the SAP .NET Conector (SAPnCO) version 3.0.
When I run the service using VS integrated IIS or IIS8, everything goes fine: I can test the service, access it from a test console application and can access it from Windows Mobile Emulator.
However, we where about to start some preliminar tests with the final users and we still didn`t have a proper server to deploy the WCF application, so I had to make a contingency server using Windows XP and IIS express 7.5 (I was not able to make it work on IIS 5.1).
I know that IIS Express is for local access only, but I followed this tutorial to open ti to the LAN: TUTORIAL.
Doing so I can acess the service signature via browser and see the WSDL file.
Everytime i try to acess the service I get the error message "Method or operation is not implemented". I`ve been looking for some similar problem over the internet for the past 4 hours without success.
Here`s what I managed to do so far:
Host a default WCF sample service on IIS Express 7.5 and use the service remotely: ok;
Reduce the scope of the original service to the minimal only: still get the same error;
So, I still don't know what can be causing this or how to solve it. I kindly request for your help, please!
Here`s my code:
WEB.CONFIG
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="SAP.Middleware.Connector">
<sectionGroup name="ClientSettings">
<section name="DestinationConfiguration" type="SAP.Middleware.Connector.RfcDestinationConfiguration, sapnco"/>
</sectionGroup>
</sectionGroup>
</configSections>
<SAP.Middleware.Connector>
<ClientSettings>
<DestinationConfiguration>
<destinations>
<add NAME="QA" USER="XX" PASSWD="XX" CLIENT="XX" LANG="XX" ASHOST="XX" SYSNR="XX" MAX_POOL_SIZE="XX" IDLE_TIMEOUT="XX"/>
</destinations>
</DestinationConfiguration>
</ClientSettings>
</SAP.Middleware.Connector>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<appSettings/>
<system.web>
<compilation targetFramework="4.0" debug="true"/>
<httpRuntime/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
SERVICE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using SAP.Middleware.Connector;
namespace WCFCriarOT
{
public class Service1 : IService1
{
public string CriarOT(int areaSelecionada, int nlenr, string codMaterial, int qtdMAterial)
{
try
{
string vltyp = "", vlpla = "";
switch (areaSelecionada)
{
case 1:
vltyp = "902";
vlpla = "GR-ZONE";
break;
case 3:
vltyp = "901";
vlpla = "GFI-ZONE";
break;
case 4:
vltyp = "904";
vlpla = "DEVOLUCAO";
break;
default:
break;
}
RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination("QA");
RfcRepository SapRfcRepository = SapRfcDestination.Repository;
IRfcFunction FCriarOT = SapRfcRepository.CreateFunction("ZWM001");
FCriarOT.SetValue("I_LGNUM", "WM1");
FCriarOT.SetValue("I_BWLVS", "999");
FCriarOT.SetValue("I_MATNR", codMaterial);
FCriarOT.SetValue("I_WERKS", "120");
FCriarOT.SetValue("I_LGORT", "0001");
FCriarOT.SetValue("I_ANFME", qtdMAterial);
FCriarOT.SetValue("I_SQUIT", "");
FCriarOT.SetValue("I_VLTYP", vltyp);
FCriarOT.SetValue("I_VLPLA", vlpla);
FCriarOT.SetValue("I_VLENR", "");
FCriarOT.SetValue("I_NLTYP", "");
FCriarOT.SetValue("I_NLPLA", "");
FCriarOT.SetValue("I_NLENR", nlenr.ToString().PadLeft(20, '0'));
FCriarOT.SetValue("I_BNAME", "PAGOTR"); // receber os dados do login posteriormente
FCriarOT.Invoke(SapRfcDestination);
if (Convert.ToInt32(FCriarOT.GetValue("E_RETURN")) == 1)
{
IRfcTable RfcReturn = FCriarOT.GetTable("T_MSG");
RfcReturn.CurrentIndex = 0;
return "1";
}
else
{
return "0";
}
}
catch (Exception ex)
{
throw new NotImplementedException();
}
}
}
SERVICE SIGNATURE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WCFCriarOT
{
[ServiceContract]
public interface IService1
{
// Contrato para a operação "Criar OT"
[OperationContract]
string CriarOT(int areaSelecionada, int nlenr, string codMaterial, int qtdMAterial);
[OperationContract]
string GetData(int value);
[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);
// TODO: Add your service operations here
}
}
Exception
System.ServiceModel.FaultException`1 was unhandled
HResult=-2146233087
Message=O método ou a operação não está implementada.
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at testeDoTeste1.ServiceReference1.IService1.CriarOT(Int32 areaSelecionada, Int32 nlenr, String codMaterial, Int32 qtdMAterial)
at testeDoTeste1.ServiceReference1.Service1Client.CriarOT(Int32 areaSelecionada, Int32 nlenr, String codMaterial, Int32 qtdMAterial) in c:\Users\Documents\Visual Studio 2012\Projects\testeDoTeste1\testeDoTeste1\Service References\ServiceReference1\Reference.cs:line 119
at testeDoTeste1.Program.Main(String[] args) in c:\Users\Documents\Visual Studio 2012\Projects\testeDoTeste1\testeDoTeste1\Program.cs:line 16
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
If I have failed in provide all necessary information, please, let me know: I will provide anything I can. I really need and apretiate all your help! Tks a lot!
--------------
UPDATE 1
Since the WEB.CONFIG file is the only piece of the service that is edited to make the WCF service work with IIS Express I think this can (evetually) be the source of trouble. I`m posting the original WEB.CONFIG file, without the edits hoping that this can help someone spot the problem!
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="SAP.Middleware.Connector">
<sectionGroup name="ClientSettings">
<section name="DestinationConfiguration" type="SAP.Middleware.Connector.RfcDestinationConfiguration, sapnco"/>
</sectionGroup>
</sectionGroup>
</configSections>
<SAP.Middleware.Connector>
<ClientSettings>
<DestinationConfiguration>
<destinations>
<add NAME="QA" USER="XX" PASSWD="XX" CLIENT="XX" LANG="XX" ASHOST="XX" SYSNR="XX" MAX_POOL_SIZE="XX" IDLE_TIMEOUT="XX"/>
</destinations>
</DestinationConfiguration>
</ClientSettings>
</SAP.Middleware.Connector>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<appSettings/>
<system.web>
<compilation targetFramework="4.0" debug="true"/>
<httpRuntime/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
--------------
UPDATE 2
Found a new error, but it`s still fuzzy to me: "{"Cannot get destination QA -- no destination configuration registered"}". This destination works fine in dev, so why it is not working on IIS Express?
Anyways, here`s the complete exception:
System.ServiceModel.FaultException`1 was unhandled
HResult=-2146233087
Message=Cannot get destination QA -- no destination configuration registered
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at testeDoTeste1.ServiceReference1.IService1.CriarOT(Int32 areaSelecionada, Int32 nlenr, String codMaterial, Int32 qtdMAterial)
at testeDoTeste1.ServiceReference1.Service1Client.CriarOT(Int32 areaSelecionada, Int32 nlenr, String codMaterial, Int32 qtdMAterial) in c:\Users\Documents\Visual Studio 2012\Projects\testeDoTeste1\testeDoTeste1\Service References\ServiceReference1\Reference.cs:line 119
at testeDoTeste1.Program.Main(String[] args) in c:\Users\Documents\Visual Studio 2012\Projects\testeDoTeste1\testeDoTeste1\Program.cs:line 16
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
--------------
I have found, this exception occurs if sapnco assembly is not loaded. Try to set referenced SAP assemblies to Copy local: True.
It is not ideal solution, but it has worked for me well.
I resolved it by moving the configSections' section to the top of the app.config. Maybe the 'configSections' must be the first child section of configuration.
See here too:
Parameter 'sectionGroupName' is invalid

CommunicationException when Converting WCF Service from WsHttpBinding to NetTcpBinding

I have a self hosted .Net 4.0 WCF service that I'm trying to convert from WsHttpBinding to NetTcpBinding for performance reasons. The service works just fine with the WsHttpBinding.
Strangely enough, The service seems to work after switching to NetTcpBinding. (The service posts messages to a enterprise messaging system, and the message is posted and the client receives no error) however the following error is written to the server log:
Error: Service: MessageSenderService, Details: System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused
by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue.
Local socket timeout was '10675199.02:48:05.4775807'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.ServiceModel.Channels.SocketConnection.HandleReceiveAsyncCompleted()
at System.ServiceModel.Channels.SocketConnection.BeginReadCore(Int32 offset,Int32 size, TimeSpan timeout, WaitCallback callback, Object state)
--- End of inner exception stack trace ---
at System.ServiceModel.Channels.SocketConnection.BeginReadCore(Int32 offset,Int32 size, TimeSpan timeout, WaitCallback callback, Object state)
at System.ServiceModel.Channels.TracingConnection.BeginRead(Int32 offset, Int32 size, TimeSpan timeout, WaitCallback callback, Object state)
at System.ServiceModel.Channels.SessionConnectionReader.BeginReceive(TimeSpan timeout, WaitCallback callback, Object state)
at System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.PerformOperation(TimeSpan timeout)
at System.ServiceModel.Channels.SynchronizedMessageSource.SynchronizedAsyncResult`1..ctor(SynchronizedMessageSource syncSource, TimeSpan timeout, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.BeginReceive(TimeSpan timeout, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.TryReceiveAsyncResult..ctor(TransportDuplexSessionChannel channel, TimeSpan timeout, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.BeginTryReceive(TimeSpan timeout, AsyncCallback callback, Object state)
at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.BeginTryReceive(TimeSpan timeout, AsyncCallback callback, Object state)
Again, no error occurs on the server log when using the WsHttpBinding.
Server Config:
<service behaviorConfiguration="debugEnabled" name="My.Service">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="netTcpBindingConfig"
contract="My.Service.Contract" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
....
<behaviors>
<serviceBehaviors>
<behavior name="debugEnabled">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceThrottling maxConcurrentSessions="200" maxConcurrentCalls="500" maxConcurrentInstances="200"/>
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
....
<bindings>
<netTcpBinding>
<binding name="netTcpBindingConfig" maxReceivedMessageSize="5242880" closeTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00" openTimeout="00:01:00">
<readerQuotas maxArrayLength="5242880" />
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
We build the client binding in code, not config. That looks like this:
return new NetTcpBinding(SecurityMode.None, reliableSessionEnabled)
{
MaxBufferPoolSize = Int32.MaxValue,
MaxReceivedMessageSize = Int32.MaxValue,
ReaderQuotas = new XmlDictionaryReaderQuotas
{
MaxArrayLength = Int32.MaxValue,
MaxDepth = Int32.MaxValue,
MaxStringContentLength = Int32.MaxValue
},
ReceiveTimeout = TimeSpan.FromMinutes(1.0),
CloseTimeout = TimeSpan.FromMinutes(1.0),
OpenTimeout = TimeSpan.FromMinutes(1.0),
SendTimeout = TimeSpan.FromMinutes(1.0)
};
Any ideas out there?
EDIT: I would like to add that I see the error on every call to the service, not only under load. The request and response messages are very small so it likely not related to message size. The error is written almost instantaneously, so it it not a timeout problem.
Fixed it.
As it turns out, I was not properly closing the client proxy. For whatever reason that didn't cause a problem with the WsHttpBinding, but with NetTcpBinding it caused that error.
After putting the client proxy in a using block the problem went away.

Working with Named Pipes in WCF, PipeException thrown?

Despite many searches and read articles such as this: Exploring the WCF Named Pipe Binding - Part 1(part 2 and 3 inclusively), I haven't been able to make my service work properly.
Here's my config:
<system.serviceModel>
<client>
<endpoint address="net.pipe://localhost/GlobalPositioningService"
binding="netNamedPipeBinding"
contract="GI.Services.GlobalPositioning.Contracts.IGlobalPositioning" />
</client>
<services>
<service name="GI.Services.GlobalPositioning.Services.GlobalPositioningService">
<endpoint address=""
binding="wsHttpBinding"
contract="GI.Services.GlobalPositioning.Contracts.IGlobalPositioning">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.pipe://localhost/GlobalPositioningService"
binding="netNamedPipeBinding"
contract="GI.Services.GlobalPositioning.Contracts.IGlobalPositioning" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/GlobalPositioningService/"/>
</baseAddresses>
</host>
</service>
</services>
Then, I try to test my service through Named Pipes:
[TestFixture]
public class GlobalPositioningServiceTests {
[TestFixtureSetUp]
public void SetUpHost() {
var channelFactory = new ChannelFactory<IGlobalPositioning>(binding, new EndpointAddress(address));
channelFactory.Open();
service = channelFactory.CreateChannel();
}
private const string address = "net.pipe://localhost/GlobalPositioningService";
private static readonly Binding binding = new NetNamedPipeBinding();
private static IGlobalPositioning service;
}
And I have also tried another way using a ServiceHost instance:
[TestFixtureSetUp]
public void SetUpHost() {
host = new ServiceHost(typeof(GlobalPositioningService));
host.AddServiceEndpoint(typeof(IGlobalPositioning), binding, address);
host.Open();
service = new GlobalPositioningService();
}
And I always obtain this error with stack trace:
Error 2 Test 'GI.Services.GlobalPositioning.Services.Tests.GlobalPositioningServiceTests.GetGlobalPositionWorksWithDiacriticsInMunicipalityName("143, rue Marcotte, Sainte-Anne-de-la-P\x00E9rade",46.5736528d,-72.2021346d)' failed:
System.ServiceModel.EndpointNotFoundException : There was no endpoint listening at net.pipe://localhost/GlobalPositioningService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
----> System.IO.PipeException : The pipe endpoint 'net.pipe://localhost/GlobalPositioningService' could not be found on your local machine.
Server stack trace:
at System.ServiceModel.Channels.PipeConnectionInitiator.GetPipeName(Uri uri)
at System.ServiceModel.Channels.NamedPipeConnectionPoolRegistry.NamedPipeConnectionPool.GetPoolKey(EndpointAddress address, Uri via)
at System.ServiceModel.Channels.CommunicationPool`2.TakeConnection(EndpointAddress address, Uri via, TimeSpan timeout, TKey& key)
at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at GI.Services.GlobalPositioning.Contracts.IGlobalPositioning.GetGlobalPosition(String mailingAddress)
at GI.Services.GlobalPositioning.Services.Tests.GlobalPositioningServiceTests.GetGlobalPositionWorksWithDiacriticsInMunicipalityName(String address, Double latitude, Double longitude) in C:\Open\Projects\Framework\Src\GI.Services\GI.Services.GlobalPositioning.Services.Tests\GlobalPositioningServiceTests.cs:line 27
--PipeException C:\Open\Projects\Framework\Src\GI.Services\GI.Services.GlobalPositioning.Services.Tests\GlobalPositioningServiceTests.cs 27
For your information, I'm using:
Visual Studio 2010
Windows 7
NUnit
And my service is contained within a WCF Service Library.
It seems that you are attempting to do integration testing with a running instance of your service using the netNamedPipesBinding. To do this, you need to have both a service host providing an instance of your service and a service proxy instance to use for making calls to the service. You could try combining both the code in both of your sample TestFixtureSetup methods so that you are instantiating both the service host and the service proxy (the result of the CreateChannel method). For an example of how to do this, look at this blog post.

Unsecured WCF Service throws SecurityAccessDeniedException

Trying to get a demo service running I'm using the following config.
<bindings>
<basicHttpBinding>
<binding name="basicBinding">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsBinding">
<security mode="None">
<transport clientCredentialType="None" />
<message establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="Integration.Server.ImportServiceBehavior" name="Integration.Server.ImportService">
<endpoint name="ImportServiceSoap"
behaviorConfiguration="NoIpConfiguration"
address="soap" binding="basicHttpBinding"
bindingConfiguration="basicBinding"
contract="Integration.Server.IImportService"/>
<endpoint name="ImportServiceSoap12"
behaviorConfiguration="NoIpConfiguration"
address="soap12" binding="wsHttpBinding"
bindingConfiguration="wsBinding"
contract="Integration.Server.IImportService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Integration.Server.ImportServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="NoIpConfiguration">
<wsdlExtensions location="http://*** external server address ***/IntegrationServer/ImportService.svc" singleFile="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
The service is hosted in IIS on xp.
<authentication mode="None"/>
IIS Authentication is set to Anonymous (integrated and basic is unchecked).
What could be the reason I get SecurityAccessDeniedException?
(The execution never reaches the service class.)
Stack trace from the client
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at SyncTestApp.SyncServiceReference.IImportService.Sync(Employment[] employments)
at SyncTestApp.SyncServiceReference.ImportServiceClient.Sync(Employment[] employments) in D:\Integration\SyncTestApp\Service References\SyncServiceReference\Reference.cs:line 809
at SyncTestApp.Program.Main(String[] args) in D:\Integration\SyncTestApp\Program.cs:line 78
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

WCF service working in iis 5.1 but not working in iis 6

I developed a WCF service and silverlight client, when I host this service in windows xp having iis 5.1, it is perfectly working as expected.
When i host in windows server 2003 R2 having iis 6, it is working for initial couple of minutes (approximately 20 mins) after that it stops working..
i am getting HTTP 500 when i access service.
The setting I have used are
Anonymous access and integrated authentication both are checked.
my service config is as follows
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="SilverlightApplication1.Web.GetData.customBinding0">
<binaryMessageEncoding/>
<httpTransport/>
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
<service name="SilverlightApplication1.Web.GetData">
<endpoint address="" binding="customBinding" bindingConfiguration="SilverlightApplication1.Web.GetData.customBinding0" contract="SilverlightApplication1.Web.GetData"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
my silverlight client config is
<client>
<endpoint address="----/InternalBorrow/GetData.svc"
binding="customBinding" bindingConfiguration="CustomBinding_GetData"
contract="ServiceReference1.GetData" name="CustomBinding_GetData" />
</client>
can any body help me to trouble shoot my problem?
the exception i am getting is
System.ServiceModel.Activation.HostedAspNetEnvironment.ValidateHttpSettings(String virtualPath, Boolean isMetadataListener, Boolean usingDefaultSpnList, AuthenticationSchemes& supportedSchemes, ExtendedProtectionPolicy& extendedProtectionPolicy, String& realm)at System.ServiceModel.Channels.HttpChannelListener.ApplyHostedContext(String virtualPath, Boolean isMetadataListener)
at System.ServiceModel.Activation.HostedAspNetEnvironment.ApplyHostedContext(TransportChannelListener listener, BindingContext context)
at System.ServiceModel.Channels.HttpTransportBindingElement.BuildChannelListener[TChannel](BindingContext context)
at System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener[TChannel]()
at System.ServiceModel.Channels.MessageEncodingBindingElement.InternalBuildChannelListener[TChannel](BindingContext context)
at System.ServiceModel.Channels.BinaryMessageEncodingBindingElement.BuildChannelListener[TChannel](BindingContext context)
at System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener[TChannel]()
at System.ServiceModel.Channels.Binding.BuildChannelListener[TChannel](Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, BindingParameterCollection parameters)
at System.ServiceModel.Description.DispatcherBuilder.MaybeCreateListener(Boolean actuallyCreate, Type[] supportedChannels, Binding binding, BindingParameterCollection parameters, Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, ServiceThrottle throttle, IChannelListener& result, Boolean supportContextSession)
at System.ServiceModel.Description.DispatcherBuilder.BuildChannelListener(StuffPerListenUriInfo stuff, ServiceHostBase serviceHost, Uri listenUri, ListenUriMode listenUriMode, Boolean supportContextSession, IChannelListener& result)
at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
at System.ServiceModel.ServiceHostBase.InitializeRuntime()
at System.ServiceModel.ServiceHostBase.OnBeginOpen()
at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open()
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
--- End of inner exception stack trace ---
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
I experienced a similar issue when we were running a .NET 4.0 web application in the same app pool as web service configured to use a lower version of .NET. Make sure you are not mixing ASP .NET versions in the same application pool on the server.
Are there any errors or warnings showing up in the web server's event viewer logs that would provide you with more information about the issue?