I am trying to generate a client proxy from a WCF service library. I am using VS2005, .NET 3.0 on a Windows XP Pro workstation. The WCF service is hosted in a windows service. When I run the windows service as a console application, there are no problems. I can run svcutil.exe against that address and it generates the proxy. However, when I compile that service in release mode, and install it on the workstation using InstallUtil, I get an error "Error: Cannot obtain Metadata from net.tcp://localhost:9090/Service2 ". These are the settings I am using the app.config for the service
<behaviors>
<endpointBehaviors>
<behavior name="Test2">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="serviceBehaviour">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata />
<!--<serviceMetadata httpGetEnabled="true" />-->
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="TestBinding2" inactivityTimeout = "00:30:00" openTimeout="00:30:00"
receiveTimeout="00:30:00"
sendTimeout="00:30:00">
<binaryMessageEncoding />
<tcpTransport transferMode="StreamedResponse" />
</binding>
</customBinding>
</bindings>
A couple of shots in the dark...
Is your Windows service running? Beyond that, is your WCF service running within the Windows service? My project is also hosting a WCF service in a Windows service (you can see the general step-by-step here). Even though I have the Windows service marked to start automatically, I still have to manually start it the first time. Perhaps there is a command-line option of InstallUtil.exe that I'm not aware of that will do this for me. But the point is, if your Windows service or your WCF service inside is not running, you obviously can't see the MEX endpoint.
The other thing I noticed. Your error says that the metadata cannot be obtained from net.tcp://localhost:9090/Service2, but the base address you posted in your comment shows
net.tcp://localhost:9090/Service_2. Perhaps this is just a type-o, but it wouldn't hurt to double-check that everything is spelled correctly, especially if the add.config is hand-generated.
Related
I am trying to deploy a wcf service I have created in Visual studio.
I am almost positive it is a configuration issue in either the wcf service config or in IIS itself.
The config I am using in the service is as follows:
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="CandidateServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="500" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="SurveyService.SurveyService" behaviorConfiguration="CandidateServiceBehavior">
<endpoint address="/Survey/SurveyService" binding="netTcpBinding" name="CandidateServiceEndPoint" contract="Prometric.Census.SurveyService.ISurveyService" />
<endpoint address="/Survey/SurveyService/mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
</system.serviceModel>
I deployed the service once from visual Studio and pointed a new site on IIS with the following settings pointing to the deployment folder
Then after this within IIS you can see the site is in an unknown status:
It is from here that I can't connect to the service or find if it is running or not. I have tried the command /an : find /i "9015" and found nothing so I assume the service is not even running.
If I where to change the bindings on the WCF service and IIS to use http instead everything works fine. (Should say using http is not an option)
Also on top of not getting the service up and running I'm unsure how to test the service as TCP, Am I able to just add a service reference as you would with a http sefvice? As you can see I am pretty new to the tcp side of things and if I have left out any vital information please let me know so I can inslude it in the question.
This might help you :
https://rohitguptablog.wordpress.com/2011/06/16/configuring-wcf-service-with-nettcpbinding/
I followed this guide to make a net.tcp wcf service and it went smoothly. Also, are you sure that your folder has the required privileges? It can be tricky to use another folder than wwwroot/inetpub
I uploaded WCF service to the Azure Web Site in Free web site mode.
Now I can connect to my service at https://<mysite>.azurewebsites.net/MyService.svc using Internet Explorer in Windows Phone device and emulator without any warnings about certificate.
Next I created Windows Phone project and added Service Reference to my WCF service using url above.
My application works great in emulator but can't on Windows Phone device. I get System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. -> System.ServiceModel.FaultException: An error occurred when verifying security for the message. when calling service method.
I know about problem with self signed sertificates on Windows Phone devices. But azurewebsites.net certificate signed by Baltimore CyberTrust Root certificate. It's root for Windows Phone OS 7.1 http://msdn.microsoft.com/en-us/library/windowsphone/develop/gg521150(v=vs.105).aspx#BKMK_VeriSignBusinessUnitedStates
Is it possible to call secured WCF services hosted with Azure free web sites from Windows Phone device? Or I need buy own certificate?
My Web.config for WCF service:
<services>
<service name="SmallService.Services.MyService" behaviorConfiguration="SecureServiceBehavior">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="SecureServiceBinding"
contract="SmallService.Services.IMyService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SecureServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="DefaultRoleProvider" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="DefaultMembershipProvider" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="SecureServiceBinding">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
Thanks to this post the issue was resolved.
Apparently, the phone was a brand new, just out of the box and clock was way off. Interesting thing that Windows automatic clock synchronization did not work.
So I can call WCF service over HTTPS after setting right date and time on device. Also I can use self-signed sertificates after downloading and installing on phone (see http://wp7certinstaller.codeplex.com/ for more information).
I have a WCF service exposed as a netTcpBinding.
On the service side:
<netTcpBinding>
<binding>
<security mode="Message">
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding> ...
// Service behavior
<behavior>
<serviceCredentials>
<windowsAuthentication allowAnonymousLogons="true" />
</serviceCredentials>
</behavior>
I am unable to access this service from a anonymous user on another machine. (Error: Negotiation failed redentials could not be verified.)
What does
<windowsAuthentication allowAnonymousLogons="true" />
do?
I want my service to be accessible to both windows and anonymous users over net tcp binding. I can do this using UserName validation, but how do I do this using Windows authentication?
Thanks
Have you set the AllowedImpersonationLevel on the client?
<behaviors>
<endpointBehaviors>
<behavior>
<clientCredentials>
<windows allowedImpersonationLevel="Anonymous"/>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
or
client.ClientCredentials.Windows.AllowedImpersonationLevel =
System.Security.Principal.TokenImpersonationLevel.Anonymous;
The MSDN article Debugging Windows Authentication Errors points out the need to combine your service configuration with the client configuration mentioned by #user1467261. It points to another article on impersonation in WCF for more detail - but glossing over it, the need to combine these settings is not entirely obvious.
I am trying to authenticate my user logging from windows phone 7 using
AuthenticationService WCF which is hosted in IIS 7.
I tried it without SSL and is working fine. But I want to convert it to
https.
The error I am getting is when I hit the call to this WCF from my WP7 emulator
is :
"EndpointNotFoundException"
However my web.config has the following details:
<system.serviceModel>
<services>
<service name="System.Web.ApplicationServices.AuthenticationService"
behaviorConfiguration="AuthenticationServiceTypeBehaviors">
<endpoint contract="System.Web.ApplicationServices.AuthenticationService"
binding="basicHttpBinding"
bindingConfiguration="userHttps" address="https://localhost:700/AuthenticationService.svc"
bindingNamespace="http://asp.net/ApplicationServices/v200"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="userHttps">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="AuthenticationServiceTypeBehaviors" >
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment
aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
USING: AspNetSqlMembershipProvider and I am avoiding those details to make the point.
In my IIS 7, I have created an App pool and associated a self signed
certificate to the hosted WCF and in the SSL Settings options to "Require SSL
- selected" and "Ignore client certificates- checked"
I am able to browse to https://localhost:700/AuthenticationService.svc.
I was able to add this as a Service Reference in my phone, but when I call the
login method it is showing the error.
I have specified the end-point address and even then it is showing error.
Can anyone explain me how to debug this to get more details or any pointers to
solve "Using Authentication Service WCF via SSL"
EDIT 1 I tried using IP addresses and the svc URL when I tried accessing
the service through browser
svcutil.exe https://mcname.domain.local:700/AuthenticationService.svc?wsdl
EDIT 2 Tried disabling antivirus and firewalls and still no luck.
As per #Rajesh's comments, I installed the certificate in phone and it started working.
I tried all options of exporting .CER, .PFX and .P7B format and only P7B format worked for me to get it installed in phone.
The part of web.config file for enabling AuthenticationService WCF with SSL is
<services>
<service behaviorConfiguration="AppServiceBehaviors" name="System.Web.ApplicationServices.AuthenticationService">
<endpoint binding="basicHttpBinding" bindingConfiguration="defaultBasicHttpBinding"
bindingNamespace="http://asp.net/ApplicationServices/v200" contract="System.Web.ApplicationServices.AuthenticationService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="AppServiceBehaviors">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.web.extensions>
<scripting>
<webServices>
<authenticationService enabled="true" requireSSL="true"/>
Steps followed to make it work: http://blogs.msdn.com/b/davidhardin/archive/2010/12/30/wp7-and-self-signed-ssl-certificates.aspx
The host name must be resolvable by the http agent via DNS, WINS,
hosts file, etc.
The SSL certificate must be known by a name that matches the host
name.
The trusted root certificate must be installed with the http
agent, i.e. on the phone.
Installing the certificate on to the WP7 emulator phone was the trickiest part. As mentioned earlier the P7B file was hosted on the IIS and URL was accessed via emulator browser which helped me to install the certificate on phone (Sorry! I forgot the reference link).
After the installation, the endpoint issue disappeared and it started to work. As this is not a permanent solution (because everytime emulator is closed the CERT needs to be reinstalled), I am working on http://wp7certinstaller.codeplex.com/ code to make it work when it is hosted in IIS for testing purposes.
Thanks #Rajesh for your help.
I have seen loads of questions about this, I've spent over a day researching and trying to fix it but I've drawn a blank.
I want to deploy a WCF service onto a server connecting with HTTPS and using basic authentication. Here is my service web.config
I am using an extremely simple Calculator as a test which has a single method which adds together two numbers.
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.0" />
<customErrors mode="Off" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="UsernameWithTransport">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="Service">
<endpoint address="https://myserver.mydomain.co.uk/CalculatorService"
binding="wsHttpBinding"
bindingConfiguration="UsernameWithTransport"
name="BasicEndpoint"
contract="TestCalculator" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
In IIS 6.0 I have enabled basic authentication and required HTTPS.
I can browse to the .svc file and it asks for my credentials. I provide them and it displays the default page. However it says:
You have created a service.
To test this service, you will need to create a client and use it to
call the service. You can do this using the svcutil.exe tool from the
command line with the following syntax:
svcutil.exe
http://myserver.mydomain.co.uk/CalculatorService/Service.svc?wsdl
This will generate a configuration file and a code file that contains
the client class. Add the two files to your client application and use
the generated client class to call the Service. For example: ......
Basically, the issue seems to be that the path to the .wsdl is a http:// not an https:// and I don't think I understand why.
I am now trying to create a C# console application to test consuming the service. I cannot add the reference to the .svc path directly because it just goes around and around in a loop asking me for my username and password. If I add the reference to the .svc?wsdl then that did work but then invoking the service gives a "Method not allowed" because it is trying to use HTTP not HTTPS.
Hope I have expained this well enough. Thanks for any help.
You requires HTTPS but in the same time you allow WSDL only over HTTP. Change this:
<serviceMetadata httpGetEnabled="true"/>
To this:
<serviceMetadata httpsGetEnabled="true"/>
Now you will be able to access WSDL over https://..../....svc?wsdl but you will still have to authenticate because authentication is global for your deployed site.