error on creating WCF proxy after upgrading to .net 4.5 - wcf

I have a WCF service which was working good on .net4.0
But several days ago i upgraded the code to .net4.5 and compiled it . The Service is working fine and listening to specific port. But when i try to create a Proxy client i get an error (i was able to create a proxy client with "old" WCF service compiled on .net4.0)
This is the app.config-
<service behaviorConfiguration="ExternalSystemsService.WExternalSystemsBehavior" name="ExternalSystemsService.WExternalSystems">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="ExternalSystemsTCP" name="ExternalSystemsServiceTcpBindingEndpoint" contract="ExternalSystemsService.IWExternalSystems"/>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" name="MexTcpBindingEndpoint" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://fm6gmup4006:3220/ExternalSystemsService"/>
</baseAddresses>
</host>
</service>
and this is the error i receive (it is not related to the different end points , it is the same error if i use the endpoint as it is written in the app.config)-
C:\Program Files (x86)\Microsoft Visual Studio 11.0>svcutil.exe /language:cs /ou
t:JULeSService.cs /config:JULeSService.config net.tcp://havjules01:3020/External
SystemsService
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.18020]
Copyright (c) Microsoft Corporation. All rights reserved.
Attempting to download metadata from 'net.tcp://havjules01:3020/ExternalSystemsS
ervice' using WS-Metadata Exchange. This URL does not support DISCO.
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.18020]
Copyright (c) Microsoft Corporation. All rights reserved.
Error: Cannot obtain Metadata from net.tcp://havjules01:3020/ExternalSystemsServ
ice
If this is a Windows (R) Communication Foundation service to which you have acce
ss, please check that you have enabled metadata publishing at the specified addr
ess. For help enabling metadata publishing, please refer to the MSDN documentat
ion at http://go.microsoft.com/fwlink/?LinkId=65455.
WS-Metadata Exchange Error
URI: net.tcp://havjules01:3020/ExternalSystemsService
Metadata contains a reference that cannot be resolved: 'net.tcp://havjules01
:3020/ExternalSystemsService'.
<?xml version="1.0" encoding="utf-16"?><Fault xmlns="http://www.w3.org/2003/
05/soap-envelope"><Code><Value>Sender</Value><Subcode><Value xmlns:a="http://www
.w3.org/2005/08/addressing">a:ActionNotSupported</Value></Subcode></Code><Reason
><Text xml:lang="en-US">The message with Action 'http://schemas.xmlsoap.org/ws/2
004/09/transfer/Get' cannot be processed at the receiver, due to a ContractFilte
r mismatch at the EndpointDispatcher. This may be because of either a contract m
ismatch (mismatched Actions between sender and receiver) or a binding/security m
ismatch between the sender and the receiver. Check that sender and receiver hav
e the same contract and the same binding (including security requirements, e.g.
Message, Transport, None).</Text></Reason></Fault>
If you would like more help, type "svcutil /?"

Related

No protocol binding matches the given address' error

I am using Visual Studio 2008. I created a WCF application and when I ran the service for the first time from VS IDE (not hosted on IIS), the service opened in the web browser with the address localhost:1927/. Every time I run this service from VS IDE, it runs in the same port, i.e 1927
I wanted to change the port number (for some reason), so I gave specific address localhost:1928 in the web.config file. When I run the web service in IDE after this change, I keep getting the following error.
No protocol binding matches the given address 'localhost:1928/'. Protocol bindings are configured at the Site level in IIS or WAS configuration.
Following is the <service> section from the web.config file.
<service name="EMS.ServiceImplementation.EmployeeService"
behaviorConfiguration="EM.EmployeeServiceBehavior" >
<endpoint name="httpEndPoint"
address="http://localhost:1928/"
binding="basicHttpBinding" bindingConfiguration=""
contract="EMS.ServiceContracts.IEmployeeService" />
<endpoint name="MEXEndPoint"
address="mex"
binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
</service>
My specific questions are:
How does VS IDE run the service always on the same port which it picked in the first run? Where is this information stored? (I looked through all files in the solution but I couldn't find port 1927 mentioned anywhere).
How can I make the service run on a different port?
(Please note that, I have seen similar threads in Stackoverflow, but they relate to service hosted in IIS)`
Just leave the address attribute empty and it is solved.
You can control this in the Solution Explorer under the Project Properties. There's a tab called Web where you can tell Visual Studio whether to use the default auto-assigned port, or a specific fixed port of your choosing:
Any non-standard settings will be stored into your YourProject.csproj file.

VS2010 "Update Service Reference" to WCF where behavior extensions inspect and change messages

I'm using an encrypted timestamp to secure communications between a WCF service in my web server and another in the 'mid-tier'. In the calling service (the client in this exchange) I'm using a DLL whose class inherits System.ServiceModel.Configuration.BehaviorExtensionElement to provide functionality implementing System.ServiceModel.Description.IEndpointBehavior and System.ServiceModel.Dispatcher.IClientMessageInspector. This is glued in via the web.config file with the sections
<extensions>
<behaviorExtensions>
<add name="MessageInspectorBehavior" type="MessageInspectorDLL.MessageInspectorBehaviorExtensionElement, MessageInspectorDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<endpointBehaviors>
<behavior name="MessageInspectorEndpointBehavior">
<MessageInspectorBehavior />
</behavior>
</endpointBehaviors>
and then these are hooked up to the mid-tier WCF with entries like this one
<client>
<endpoint address="http://blah.cloudapp.net:8080/BlahService.svc"
behaviorConfiguration="MessageInspectorEndpointBehavior" binding="customBinding"
bindingConfiguration="CustomBinding_BlahService"
contract="BlahServiceReference.BlahService"
name="CustomBinding_BlahService" />
In the mid-tier there's a similar story with a System.ServiceModel.Dispatcher.IClientMessageInspector decrypting the time stamp and either processing the request or throwing a System.ServiceModel.FaultException with the error message "Invalid stamp".
This follows code examples at http://msdn.microsoft.com/en-us/library/ms733747.aspx and http://weblogs.asp.net/paolopia/archive/2007/08/23/writing-a-wcf-message-inspector.aspx
Now I have changed the mid-tier WCF. Some changes are simple (e.g. correcting a spelling mistake in a method name "retrive" -> "retrieve") while some adds more substantial functionality and I want to update the service recerences in the client. In VS2010 I right-click on the service references that will need updating and select "Update Service Reference". VS2010 connects to the mid-tier WCF ("downloading service information") and then throws the error
The configuration for the service reference could not be updated due to the following issue: The type 'MessageInspectorDLL.MessageInspectorExtensionElement, MessageInspectorDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' registered for extension 'MessageInspectorBehavior' could not be loaded. (C:\TFS\Blah\Blah\web.config line 80)
What's wrong? Is there something I need to set up for the update service reference to correctly use the message inspector DLL?
Though it is possible that the DLL or the web.config have errors that seems unlikely since the client will connect to the previous mid-tier which is up on Azure, and that has the same encrypted timestamp inspection.
I've found an answer. Adding the MessageInspectorDLL as a reference to the ASP application fixed it for me.

WCF - remote service without using IIS - base address?

I'm trying to get my head around the addressing of WCF services.
We have a client-server setup where the server occasionally (maybe once a day) needs to push data to each client. I want to have a lightweight WCF listener service on each client hosted in an NT service to receive that data. We already have such an NT service setup hosting some local WCF services for other tasks so the overhead of this is minimal.
Because of existing legacy code on the server I believe the service needs to be exposed as ASMX and use basicHttpBinding to allow it to connect.
Each client is registered on the server by the user (they need to configure them individually) so discovery is not the issue.
My question is, how does the addressing work? I imagine the user entering the client's address on the server in the form
http://0.0.0.0/MyService
or even
http://hostname/MyService
If so, how do I configure the client service in its App.config? Do I use localhost?
If not then what is the reccommended way of exposing the service to the server?
Note:
I don't want to host in IIS as that adds extra requirements to the hardware required for the client.
The clients will be almost certainly located on LANs, not over the public internet
You configure the base address of the service like so:
<system.serviceModel>
<services>
<service name="Ns.FooService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:9999" />
</baseAddresses>
</host>
<endpoint
address="/foo"
binding="basicHttpBinding"
contract="Ns.IFooContract" />
</service>
</services>
</system.serviceModel>
And then your service could be accessible through http://servename:9999/foo. You may take a look at this article for more information.

WCF-The document was understood, but it could not be processed

I have a WCF service which i deployed on my test server. Trying to use it on my test project and I added a reference and I get this error
The document was understood, but it could not be processed.
- The WSDL document contains links that could not be resolved.
- There was an error downloading 'http://localhost:8731/somewhere.nowhere.com/service1/?xsd=xsd2'.
- Unable to connect to remote server
- No connection could be made because the target machine actively refused it
Metadata contains a reference that cannot be resolved: 'http://192.1.1.1/TestService/somewhere.nowhere.com.svc?wsdl'.
Content Type application/soap+xml; charset=utf-8 was not supported by service . The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.
I had my test app working before I added wsdlextras to my service project to include wsdl documentation.
This is the schema from my wsdl:
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://localhost:8731/somewhere.nowhere.com/?xsd=xsd2" namespace="http://tempuri.org/"/>
<xsd:import schemaLocation="http://localhost:8731/somewhere.nowhere.com/?xsd=xsd1" namespace="http://schemas.datacontract.org/2004/07/TestService"/>
<xsd:import schemaLocation="http://localhost:8731/somewhere.nowhere.com/?xsd=xsd0" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
<xsd:import schemaLocation="http://localhost:8731/somewhere.nowhere.com/?xsd=xsd3" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
</xsd:schema>
</wsdl:types>
Attempt to Fix 1:
I changed my
<host>
<baseAddresses>
<add baseAddress />
</baseAddresses>
</host>
so my addresses in my schema all mmatch up. I can update my service reference on my test project, however I cannot view any of my methods exposed by my wcf service.
My service is deployed on windows 2003 and my test app is on XP as well
Answer is here:
WCF IIS server configuration
in short...
The problem was with WCF identity permissions. The identity that is used for the application pool that hosts the WCF service must have full NTFS permissions on the %WINDIR%\temp folder. After changing that permission to my identity (LOCAL SERVICE) on C:\Windows\Temp I was able to add service reference to WCF service.
From the error message it looks as if it cannot find the imported xsd file xsd2.
The call to the service looks like it is on port 80, but the include files are referenced from point 8731.

WCF service configuration file question regarding <baseAddresses>

From what I've seen the tag is ignored when hosting a WCF service in IIS. I understand that when self-hosting this is required but is this harmful or even used when operating under IIS?
ex.
<system.serviceModel>
<service blah blah blah>
<host>
<baseAddresses>
<add baseAddress="http://localhost/blah" />
</baseAddresses>
</host>
</service>
</system.serviceModel>
From what I've seen you can take a config file describing a service from one machine and use that on a completely different machine and it works fine. It looks as if IIS completely ignores this section.
Thanks,
kyle
As you have guessed, the baseAddresses element is completely ignored when hosting in IIS. The service's base address is determined by the web site & virtual directory into which your wcf service is placed.
Even when self-hosting, baseAddresses is not required. It is merely a convenience that avoids you having to enter a full address for each endpoint. If it is present, the endpoints can have relative addresses (relative to the base address, that is).
base address required for selfhosting. IIS/WAS hosts ignores the base address.
According to the MSDN Microsoft documentation in the below link, midway through the page in the Note section states, "Services hosted under Internet Information Services (IIS) or Windows Process Activation Service (WAS) use the virtual directory as their base address."
http://msdn.microsoft.com/en-us/library/ee358768(v=vs.110).aspx