(Please read comment as i have a fix)
Hi,
I have created a WCF Service that i am hosting in IIS 7.5 on Windows 7 using .net 4.0
The service is hosted both on http and net.tcp.
net.tcp://localhost:42/Service/MyService.svc
http://localhost:43/Service/MyService.svc
I have tested my service using the WcfTestClient and it seems to work correctly through both basicHttp and netTcp.
However, when i try consume this service through my ASP.NET Website, i receive an error when trying to go through nettcp
My client end point looks as follows
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Generic_HttpBinding" sendTimeout="00:01:00" receiveTimeout="00:01:00" maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000000">
<security mode="None"/>
<readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000"/>
</binding>
</basicHttpBinding>
<netTcpBinding>
<binding name="Generic_Binding" sendTimeout="00:01:00" receiveTimeout="00:01:00" maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000000">
<security mode="None"/>
<readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000"/>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint name="EndPointHttp" address="http://localhost:43/Service/MyService.svc" binding="basicHttpBinding" bindingConfiguration="Generic_HttpBinding" contract="NameSpace.Services.Contracts.IService"></endpoint>
<endpoint name="EndPoint" address="net.tcp://localhost:42/Service/MyService.svc" binding="netTcpBinding" bindingConfiguration="Generic_Binding" contract="NameSpace.Services.Contracts.IService"></endpoint>
</client>
Now i call the service in the exact same way just swapping my end point name
var factory = new ChannelFactory<IService>(SuppliedEndpointName);
factory.Open();
var proxy = factory.CreateChannel();
var result = proxy.SomeServiceMethod();
If i pass this method the basicHttpBinding it works perfectly.
The second i swap to nettcp, i receive this error immediately:
Exception: 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 '00:01:00'.
Inner Exception: An existing connection was forcibly closed by the remote host
Error Code: 10054
Please can anyone help me, it driving me crazy.
I have definately installed the WCF HTTP Activation and NON HTTP Activation features.
I have setup my binding to be both HTTP and net.tcp on differen't ports.
I have set my enabled protocols to http,net.tcp in IIS.
I have disabled my firewall.
I have run aspnet_regiis -i for .net 4.0
HELP!
I finally found that changing my security mode to transport fixes the problem.
However my service has it security mode set to none.
So why does my client only works with security mode transport on?
netTcpBinding by default transport security with both signing and encryption. Try removing the security element (<security mode="None"/>).
Also
Ports under 8000 (and definitely under 1024) are normally not safe to be used for services. Try using safe ports.
Related
I'm working on some code refactoring within an existing application.
The application is already hosted and it works fine.
I have WCF services hosted by an external Windows service.
Indeed, I'm working locally and I'm trying to test some code implementations in the Pre prod environment.
So, this is the proxy configuration within the basicHttpBinding code:
<bindings>
<basicHttpBinding>
<!--proxy configuration must be provided-->
<binding name="BindingTimeSheet" maxReceivedMessageSize="6000000" useDefaultWebProxy="false" proxyAddress="http://xxx.xxx.x.x:xxxx" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00">
<readerQuotas />
<security mode="Transport">
<transport clientCredentialType="Ntlm" />
</security>
</binding>
</basicHttpBinding>
</bindings>
and this is project server endpoint configuration:
<client>
<endpoint address="https://xxxxxxxxxx.asmx" binding="basicHttpBinding" bindingConfiguration="BindingTimeSheet" contract="ProxyClientJeanDoe.JeanDoeSoap" name="JeanDoeSoap" />
</client>
I'm receiving this exceptions:
Inner Exception 1: EndpointNotFoundException: There was no listening
endpoint on https://xxxxxxx.asmx that could accept the message. This
is often due to an incorrect address or SOAP action. If present, see
the InnerException element for more information.
Inner Exception 2: WebException: Can not connect to remote server
Inner Exception 3: SocketException: A connection attempt failed
because the connected party did not respond properly after a certain
amount of time or an established connection failed because the login
host did not respond xxx.xxx.xx.x:xxxx
I have tested the WSDL services and they are working fine but the proxy address is not responding
I have already tried to set the anonymous authentication enabled and I'm working in a local machine where the Internet connection is using a proxy server and it's impossible to configure the firewall for Security reasons.
thanks for your understanding
Finally, The problem was related with the BypassProxyOnLocal flag.
It was enabled so the requests to local Internet resources was not using the proxy server.
This configuration placed into the Web.config works fine.
<system.net>
<defaultProxy useDefaultCredentials="true">
<proxy usesystemdefault="True" proxyaddress="http://xxxxxxxxxxx:8080"
bypassonlocal="False"/>
</defaultProxy>
</system.net>
Thank you.
I'm trying to setup my Web service client to use fiddler proxy by setting it in the webhttpbinding configuration file as follows:
<bindings>
<webHttpBinding>
<binding name="RestBinding" proxyAddress="http://localhost:8888"
useDefaultWebProxy="false">
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2172/RestServiceImpl.svc"
binding="webHttpBinding" behaviorConfiguration="RestService"
bindingConfiguration="RestBinding"
contract="IWS.IRestServiceImpl" name="Rest"/>
</client>
This doesn't seem to work. I don't see anything logged in fiddler when calling the webservice from the client. I know the call is being made because I get a response back from the service.
I can't seem to figure out what I'm doing wrong.
Any help is appreciated!
Thanks!!
The .NET Framework does not send requests for "localhost" to any proxy, including Fiddler. To workaround this, try to use your machine name instead as the endpoint address (e.g. http://mymachine:2172/RestServiceImpl.svc).
Also, take a look on Using Fiddler with IIS7 Express
I have deployment of WCF service on IIS 7 with support for Non-HTTP enabled
Under one project, I have exposed 8 different services with wsHttp endpoints which works fine.
I want to also expose NetNamedPipe bindings for the same services.
My sample NetNamedPipe bindings . . .
<netNamedPipeBinding>
<binding name="PassportIPCBasicEndpoint"
closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00"
sendTimeout="00:05:00"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" transferMode="Buffered"
hostNameComparisonMode="Exact" >
<readerQuotas
maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="Transport">
<transport protectionLevel="None" />
</security>
</binding>
</netNamedPipeBinding>
And my Service tags
<service behaviorConfiguration="default" name="MyAccountService.AccountService">
<host>
<baseAddresses>
<add baseAddress="http://localhost/MyAccountService/v1.0/AccountService.svc" />
</baseAddresses>
</host>
<endpoint name="PassportIPCBasicEndpoint"
address="net.pipe://localhost/MyAccountService/v1.0/AccountService.svc"
binding="netNamedPipeBinding"
bindingConfiguration="PassportIPCBasicEndpoint"
contract="MyAccountService.IAccountService"/>
</service>
This gives me following exception :
The protocol 'net.pipe' is not supported.
[InvalidOperationException: The protocol 'net.pipe' is not supported.]
System.ServiceModel.Activation.HostedTransportConfigurationManager.InternalGetConfiguration(String
scheme)
[InvalidOperationException: The ChannelDispatcher at
'net.pipe://localhost/MyAccountService/v1.0/AccountService.svc' with
contract(s) '"IAccountService"' is unable to open its
IChannelListener.]
I have added entry for http,net.pipe in advanced site settings in IIS.
Non-HTTP support for WCF service is also installed and enabled through control panel settings.
out of 8 .svc services only one such service is able to get hold of port and I can browse it's .SVC endpoint
all other services when configured for netnamedPipe binding give me above errors.
Can some body guide me, what needs to be done to make them all get hold on port and be accessible.
This problem was with enabling the protocols at the correct place.
Previously i had enabled net.pipe protocol at site level.
After enabling net.pipe protocol at each virtual path of the hosted services.
It worked.
The netNamedPipe binding is only for on-the-same-machine communication - you cannot call such an endpoint from a remote machine.
Is that what you're trying to do??
netNamedPipe binding is great for intra-application communication on the same machine - but not for anything else, really.
My computer have a proxy server defined globally (in internet options configuration).
I have a .Net 4 application that use a WCF client to a remote host. The client code has been generated by VS add service reference dialog. As my proxy can't reach the host, each call ends with a communication exception.
How can I set up my client configuration to not use the default proxy ?
You can tell WCF not to use the default proxy by setting the BasicHttpBinding.UseDefaultWebProxy to false:
<client>
<endpoint address="http://server/myservice"
binding="basicHttpBinding"
contract="IMyService" />
</client>
<bindings>
<basicHttpBinding>
<binding useDefaultWebProxy="false" />
</basicHttpBinding>
</bindings>
In your Binding configuration, set useDefaultWebProxy=false
We have a system where the users access a web server, the web server then calls a WCF service.
We would like the call to the WCF service to be made in the security context of the windows identity of the application pool on the web server.
What is the best way to do this? Can it be done purely through configuration in the web.config file.
Thanks
Shiraz
Yes, you should be able to do this, all in config:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="WinAuth" mode="Transport">
<transport clientCredentialType="Windows" />
<bindings>
</netTcpBinding>
</bindings>
</system.serviceModel>
Of course, depending on your binding, you'd have to use a different tag under the <bindings> parent node - and of course, not all bindings support all security modes.....
In your endpoint, use the appropriate binding and then just reference this config:
<endpoint name="WCFService" address="......."
binding="netTcpBinding"
bindingConfiguration="WinAuth"
contract="......" />
That should do it! And of course, if you need message security instead of transport security, you can do that, too.
In your WCF service method, you can check to see whether or not the Windows credentials have been sent over, and what they are, by checking:
ServiceSecurityContext.Current.WindowsIdentity
This will be NULL if you don't have a Windows caller, otherwise it will show who called you.
Marc