I have recently been asked to make changes to a wcf service which uses ssl. The developer who created the project no longer works for us. The problem I am having is that when I run it in visual studio 2015 I get an error pops up in a dialog box titled:
"Failed to add service. Service metadata may not be accessible. Make sure your service is running and exposing metadata"
The error details are:
Error: Cannot obtain Metadata from https://localhost:50257/AssignmentImport.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: https://localhost:50257/AssignmentImport.svc Metadata contains a reference that cannot be resolved: 'https://localhost:50257/AssignmentImport.svc'. An error occurred while making the HTTP request to https://localhost:50257/AssignmentImport.svc. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server. The underlying connection was closed: An unexpected error occurred on a send. The handshake failed due to an unexpected packet format.HTTP GET Error URI: https://localhost:50257/AssignmentImport.svc There was an error downloading 'https://localhost:50257/AssignmentImport.svc'. The underlying connection was closed: An unexpected error occurred on a send. The handshake failed due to an unexpected packet format.
In the web.config file the service model is:
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<services>
<service name="NetiveApi.IisHost.TimesheetImport" behaviorConfiguration="metadatadiscov">
<endpoint name="TimesheetWs" binding="wsHttpBinding" bindingConfiguration="WsHttpBinding" contract="NetiveApi.IisHost.ITimesheetImport"/>
<endpoint name="mexHttpsBinding" binding="mexHttpsBinding" address="mex" contract="IMetadataExchange"/>
</service>
<service name="NetiveApi.IisHost.AssignmentImport" behaviorConfiguration="metadatadiscov">
<endpoint name="AssignmentWs" binding="wsHttpBinding" bindingConfiguration="WsHttpBinding" contract="NetiveApi.IisHost.IAssignmentImport"/>
<endpoint name="mexHttpsBinding" binding="mexHttpsBinding" address="mex" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadatadiscov">
<!-- 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="false"/>
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<!-- Use your own port numbers -->
<!--<add scheme="http" port="8080" />-->
<add scheme="https" port="444"/>
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WsHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
Service Contract for assignment
[ServiceContract]
public interface IAssignmentImport
{
[OperationContract]
Acknowledgement ImportAssignment(string xml, string system, Guid authenticationToken);
}
Service Contract for timesheet
[ServiceContract]
public interface ITimesheetImport
{
[OperationContract]
Acknowledgement ImportTimesheet(string xml, string system, Guid authenticationToken);
[OperationContract]
string ApiActive();
}
I have read a number of articles about self signed certificates but they seem to suggest this is for use under IIS rather than IIS express in visual studio.
Any help and advice on this subject would be great.
Thanks
First thing you should check is whether you are able to browse the wsdl through https://localhost:50257/AssignmentImport.svc.
I don't think you can because of missing behavior configuration.
<service name="NetiveApi.IisHost.TimesheetImport" behaviorConfiguration="metadatadiscov">
Now name your service behavior which has overridden the default implementation of the metadata.
<behavior name="metadatadiscov" >
<!-- 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="false"/>
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<!-- Use your own port numbers -->
<!--<add scheme="http" port="8080" />-->
<add scheme="https" port="444"/>
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
Now you should be able to browse the wsdl.
https://localhost:50257/AssignmentImport.svcIf not kindly post your service contract as well as Base address configuration.
Related
I know there are lot of posts for this issue and I tried solutions from most of them but nothing seems to work.
I have a WCF service which was working fine in the Dev box when hosted on IIS and I moved this to the UAT box app server and I am able to access it and test if from the test client. So I now hosted my MVC application on the web server and from the web server browser I am able to access the service but when I run my web application which consumes the service it throws the following error.
Error Detail:- There was no endpoint listening at http://servername/AC.IS.BLService/CustService
.svc that could accept the message. This is often caused by an incorrect
address or SOAP action. See InnerException, if present, for more details.
Error TargetSite:- ACL.IS.BLWebSite.ViewModels.HomeAccountStatusViewModel
ValidateLogin(ACL.IS.BLWebSite.ViewModels.HomeAccountStatusViewModel)
Inner Exception:- System.Net.WebException: The remote server returned an
error: (404) Not Found. at System.Net.HttpWebRequest.GetResponse() at
System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannel
Request.WaitForReply(TimeSpan timeout)
So,I tried hosting the service and the web application together on the same server and I still have the same problem. The following are my config files for both the service and client
Client.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICustomerService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://servername/ACL.IS.BLService/CustService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICustService"
contract="BLService.ICustService" name="BasicHttpBinding_ICustService" />
</client>
</system.serviceModel>
Server Config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICustService" />
</basicHttpBinding>
</bindings>
<services>
<service name="ACL.IS.BL_WebServices.CustService" behaviorConfiguration="mexBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/"/>
</baseAddresses>
</host>
<endpoint address="CustService" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICustService" contract="ACL.IS.BL_WebServices.ICustService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehavior">
<!-- 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="false"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
its a windows 2012 server. IIS 8.5. Could somebody please help.
Just to mention..there is a firewall as well..does it have something to do with port numbers ?
Your server config says that it listens on port 8080:
baseAddress="http://localhost:8080/"
while client connects to port 80:
address="http://servername/ACL.IS.BLService/CustService.svc"
I think they should match.
You appear to have a contract mismatch.
Client;
contract="BLService.ICustService"
Server;
contract="ACL.IS.BL_WebServices.ICustService"
These need to match
I think it may be due to not having/requiring any base address to be specified in the config. Everything else works fine, including publishing WSDL, calling the service, etc. but when I add a MEX endpoint and try to access it, it returns 503 service unavailable.
My web.config looks like this:
<system.serviceModel>
<bindings>
<basicHttpsBinding>
<binding name="ServiceBinding" />
</basicHttpsBinding>
</bindings>
<services>
<service name="MyServices.CatService" behaviorConfiguration="MyBehavior">
<endpoint address="" binding="basicHttpsBinding" bindingConfiguration="ServiceBinding" contract="MyServices.ICatService"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<!-- 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="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
When I browse to my service, I get the message:
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://[mypc]/MyServices/CatService.svc/mex
I'm reasonably sure it's to do with the way the endpoints are defined, but I don't know how to fix it. Any ideas?
Solved - the mex example above that I copied and pasted in is http, not https. I changed it mexHttpsBinding and it worked great. I think http didn't work due to some configuration of running http locally but I am not sure.
i want hosting a WCF service on a opensuse 11.2 with apache 2.2.13 and mono 2.10.2, but i don't have found anything that explain me how in detail, and all my tentative are wrong. Someone may help me?
Thanks in advance
F.
i have partially resolved my problem using visual studio for creating the service and generating in another project the proxy. Then publishing on linux machine the service with this web.config configuration:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NewBinding0" />
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WcfService2.Service1Behavior"
name="WcfService2.Service1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"
contract="WcfService2.IService1" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService2.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="false" />
<!-- 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>
</system.serviceModel>
and adding this two lines to mod_mono.conf
MonoServerPath "/usr/bin/mod-mono-server4"
ddType application/x-asp-net .svc
The problem i mean is only that on mono the mechanism of wsdl doesn't work. But calling normally the service works.
This is the error if i call from my prowser the service:
<Fault><Code><Value>a:InternalServiceFault</Value></Code><Reason><Text xml:lang="">The server was unable to process the request due to an internal error. The server may be able to return exception details (it depends on the server settings).</Text></Reason></Fault>
Following are binding configurations of my WCF service.
Anonymous access: off
Basic authentication: on
Integrated Windows authentication: off !!
support HTTP protocol .
I am getting an following exception while accessing my WCF service:
Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType ="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WMWcfWebServiceLib.Service1Behavior"
name="WMWcfWebServiceLib.WMWcfWebService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBinding"
contract="WMWcfWebServiceLib.IWMWebService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/WMWcfWebServiceLib/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WMWcfWebServiceLib.Service1Behavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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="False" />
</behavior>
</serviceBehaviors>
</behaviors>
Please Help!!
Edit
I am able to access the WCF service through the web browser with the following changes:
Changes the security mode to TransportCredentialOnly and Removed the Mex Endpoint, but now as obvious I am not able to create the proxy on the client side.
Please let me know where I am wrong ?
If you want to support HTTP only your configuration is not used at all because mode="Transport" demands HTTPS. First find why config is not used (probably wrong type name in service element). Next change security mode to TransportCredentialOnly. But be aware that TransportCredentialOnly + Basic authentication means that HTTP requests will contain plain text Windows user name and password. In most cases such implementation will not pass any security audit.
Edit:
You can create proxy without mex endpoint if you still support httpGetEnabled in service metadata behavior.
I want to use netTCPbinding, so I've changed my web config as below. I'm experiencing this error:
Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
How can this be solved?
<services>
<service name="DXDirectory.DXDirectoryService" behaviorConfiguration="DXDirectory.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="netTcpBinding" bindingConfiguration="WindowsSecured" contract="DXDirectory.IDXDirectoryService">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:2582/DXDirectoryService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DXDirectory.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="false" />
<!-- 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="false" />
<serviceAuthorization principalPermissionMode="UseWindowsGroups" />
<!--<serviceCredentials>-->
<!--<userNameAuthentication userNamePasswordValidationMode="Custom"
membershipProviderName="CustomUserNameValidator"/>-->
<!--</serviceCredentials>-->
</behavior>
</serviceBehaviors>
</behaviors>
HMm... you've added the base address to your services/host section ok.
Quick question: are you self-hosting, or hosting in IIS ?? Which version of IIS ??
IIS5/6 only support HTTP connections - you cannot host a NetTCP in IIS 5/6.
In IIS7, you have to manually go through a series of steps to enable non-HTTP bindings, but it's possible. See this MSDN article on how to achieve this.
Self-hosting is the best option - you get all bindings and are in total control of your service being hosted.
Marc
Here is a NetTcpBinding basic example from msdn. See if this can help you.
EDIT:
And here is a related SO question.
I cant see section in your config file, can u please
please add this
<netTcpBinding>
<binding name="WindowsSecured">
<security mode="none"/>
</binding>
</netTcpBinding>