WCF DTO transfer problem "Cannot convert from XX to XX" - wcf

I'm having the following problem:
cannot convert from 'MyProject.DataLayerServiceRef.MyDTO'
to 'WCFService.MyDTO'
when i'm trying to call a method from the service to add an object to the database.
The problem is that my servicereference method is given a MyProject.DataLayerServiceRef.MyDTO TYPE while the service method wants a WCFService.MyDTO TYPE
What am I doing wrong here..? I'm new to WCF and simply cannot see what I have done wrong
What I'm trying to achieve is to create a new object client-side and use my wcf service to save it to the database (I have created a EDMX file in the service).
EDIT
now I get a new error..:
System.ServiceModel.FaultException:
The server was unable to process the
request due to an internal error. For
more information about the error,
either turn on
IncludeExceptionDetailInFaults (either
from ServiceBehaviorAttribute or from
the configuration
behavior) on the server in order to
send the exception information back to
the client, or turn on tracing as per
the Microsoft .NET Framework 3.0 SDK
documentation and inspect the server
trace logs. 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
IDataLayerService.GetAnsatList() at
DataLayerServiceClient.GetAnsatList()
in
H:\Projekt\DataLayerServiceRef.cs:line
233 at
Projekt.Controllers.HomeController.Index()
in
H:\Projekt\Controllers\HomeController.cs:line
27
I've tried setting the "includeExceptionDetailInFaults", but that doesnt seem to help.. :(
The error occurs in this line of the homecontroller.cs:
AnsatDTO[] list = dls.GetAnsatList();
dls is my proxy and the GetAnsatList() method is a service method

Problem solved by creating a new WCF service from scratch.. :)

Related

Calling Web API from SQL Server when API is configured to use Windows Authentication

I have an internal web site that is secured with Windows Authentication. This works correctly.
Contained in the site I have several methods accessible via Web API.
The intent is to automate the calling of those API methods from a SQL 2008 SSIS job. This is our preferred process so that all scheduled tasks are in one place.
When I call the Web API from the desktop of a user that is in the appropriate AD security group the Web API call works properly but when I try to call the API from the SSIS job I get an access error. I have tried putting valid credentials in the SSIS job but that didn't work, I still get the same error.
What security context is this job running under? Can I add that security context to the AD group and get everything working?
Web API under a different authentication process? Can this be configured in web.Config or on the page itself?
**** Update
I've confirmed that the account I expected is the account that is doing the call.
I have more details on the exact error message being returned:
SSIS package "XXManagerAdd.dtsx" starting.
Error: 0x1 at Trigger API: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.WebClient.OpenRead(Uri address)
at ST_4b03489e84c44950b38aac6439e328ee.csproj.ScriptMain.Main()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
Task failed: Trigger API
SSIS package "XXManagerAdd.dtsx" finished: Success.

ProcessGetResponseWebException when calling wcf method hosted in azure from visual studio

I have a wcf web role hosted in azure which has methods to add, delete update etc. When I step through the code in vs2012 and call the add method I receive a ProcessGetResponseWebException.
The add method takes a job object as parameter. This is the only method that's causing a problem. Any method that doesn't have a job object as a parameter works fine.
The service uses message security with custom username. This is not the problem as I've removed this and am still having same problem and also the other methods work when security is left in place.
The strange thing is if I install my client as a service and start it it all works fine and there are no problems it only happens when run from visual studio. I've tried this on another machine using visual studio 2010 and it doesn't work on that either.
When I call the add method from vs and then logon to azure virtual machine I can see that IIS is using 100% of the cpu.
The bindings are correct as I've went through them, all message sizes are set to the max, timeouts are set to 10 mins. I've even copied the config from the running service that's working just in case and it still doesn't work.
I changed the add method to take a string as a parameter and it works, so it's something with the job object that's passed but can't figure out what and confused as to why it works when installed as service.
I've enabled intellitrace but that doesn't show any exceptions.
Anyone have any suggestions of what I could try next?
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
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 MobileJobs.CloudService.IJobService.AddJob(Job newJob)
at MobileJobs.CloudService.JobServiceClient.AddJob(Job newJob) in

Getting "Unrecognized message version" exception attempting to call WCF service

I have a WCF service that works locally and previously worked (prior to minor changes) on a separate server. It now throws an "Unrecognized message version" CommunicationException. What might be causing this?
In troubleshooting I've found that it's happening somewhere within the WCF "magic" on the server before it resolves to use the custom binding defined for it.
The server itself has had some monkeying around done on it lately to add SSL and change host names so I'm wondering if there's something server-specific happening between IIS (7.5) finding the service and my code getting called.
My services inherit from a base class that includes a simple Ping method that just returns success once contacted. This has worked on a all other internal server deployments, but even calling this method now give the unrecognized message version.
Calling code just uses a VS-generated Service Reference to create an instance then call it:
var MyService = new MyNamespace.MyServiceClient();
var result = MyService.Ping();
Update
The stack trace (no InnerException exists) makes me wonder if it's SOAP-related:
Server stack trace:
at System.ServiceModel.Channels.ReceivedMessage.ReadStartEnvelope(XmlDictionaryReader reader)
at System.ServiceModel.Channels.BufferedMessage..ctor(IBufferedMessageData messageData, RecycledMessageState recycledMessageState, Boolean[] understoodHeaders, Boolean understoodHeadersModified)
at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.ReadMessage(ArraySegment`1 buffer, BufferManager bufferManager, String contentType)
at System.ServiceModel.Channels.MessageEncoder.ReadMessage(Stream stream, BufferManager bufferManager, Int32 maxBufferSize, String contentType)
at System.ServiceModel.Channels.HttpInput.ReadChunkedBufferedMessage(Stream inputStream)
at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception& requestException)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, 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 Lenderprise.WebServiceHost.Test.LLSSTitleSearch.ITitleSearch.Ping()
at Lenderprise.WebServiceHost.Test.LLSSTitleSearch.TitleSearchClient.Ping() in D:\LLN\DEV\LenderPrise\WebServices\TitleSearchWebServiceHost.Test\Service References\LLSSTitleSearch\Reference.cs:line 138
at Lenderprise.MainWindow.RunAsLibraryButton_Click(Object sender, RoutedEventArgs e) in D:\LLN\DEV\LenderPrise\WebServices\TitleSearchWebServiceHost.Test\MainWindow.xaml.cs:line 91
Any Suggestions?
A pretty niche case here: We have a load balancer (F5) that also manages the SSL certs. Requests coming in looked to be getting forwarded to the server correctly, but also were redirecting back to itself as well. I'm not network engineer enough to know all the details but it was F5 configuration not WCF.

The underlying connection was closed: The connection was closed unexpectedly

I am using Visual Studio 2010 & SQL Server 2008 R2. I have created a project to sync SQL Server CE (*.sdf) file to SQL Server using a WCF service.
It is working fine when I have small SQL Server CE file (18 MB) but when I tried to sync using a large SQL Server CE file (38 MB) then an error happens.
I have increased size of many parameters in web.config of the WCF service & app.config of my application.
But the error keeps occurring.....
The underlying connection was closed: The connection was closed
unexpectedly.
StackTrace :
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Microsoft.Synchronization.Data.ServerSyncProviderProxy.GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
at Microsoft.Synchronization.SyncAgent.DownloadChanges(SyncGroupMetadata groupMetadata)
at Microsoft.Synchronization.SyncAgent.DataSynchronize()
at Microsoft.Synchronization.SyncAgent.Synchronize()
at SyncSample.AccountsListing.btnSync_Click(Object sender, EventArgs e)
Above exception means that there's something unexpected happened due to which connection is closed, and most of the time it's due to some exception on service side which caused to reject the request. You can enable WCF tracing for the service and check the logs to confirm the exception. Most of the time, exception message suggests you what went wrong ;-)
HTH,
Amit
I was recently getting errors like this from a web service when I had not configured it correctly to handle enough data eg: maxBufferPoolSize, maxReceivedMessageSize and the like.
Also if you are sending a large array the service behaviour and endpoint behavior sections of these files may need:
<dataContractSerializer maxItemsInObjectGraph="array size here"/>
as Amit suggested, you should try enabling WCF Tracing. the error you are getting can mean many things happening on the server side.
unless you're building a Windows Mobile app, I suggest you use the newer SqlSyncProvider/SqlCeSyncProvider/SyncOrchestrator combo as well instead of the older SqlCeClientSyncProvider/DBServerSyncProvider/SyncAgent (the same one used by Local Database Cache Project Item)
the newer providers has functionalities around batching if data size is really your problem.

Failed to establish a backside connection

When my ASP.NET WCF service calls another ASP.NET WCF service the following is returned:
Failed to establish a backside connection
Server stack trace:
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 ServiceNameSpace.Service.ServiceType.getStatus(getStatusRequest request)
Any ideas?
Update 10:12 AM - After looking at this for a while: my guess is the other service doesn't like some of the data we pass to it. I think it's not validating inputs and then throws an exception on a null reference or perhaps a DB query.
PS. Names of components in the last stack trace line changed for security\privacy reasons.
PS. I tried to do a search. I pasted my title into the search box and then clicked on search to the left of the input box. Nothing happened.
I would search the source code of the calling wcf service for the term Failed to establish a backside connection.
I am fairly certain there is no built-in exception message in the WCF stack with that exact terminology.
Once you have found the code which throws the exception then you will be step closer to solving the problem ;)