WCF - Base Address issue with SOAP UI testing - wcf

I have a service deployed in IIS and the service under the node of defaultwebsite ->Example.SampleService
underneath i have the SVC file called SampleService.svc
so,m when I browse it in IE like http://localhost/Example.SampleService/SampleService.svc the brwoser shows it fine.
I try to test it with SOAP UI by adding the wsdl with same address as mentioned about the project got created in SOAPUI but when I submit the request I get the error like :
HTTP/1.1 404 Not Found
Cache-Control: private
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 19 Oct 2015 07:54:36 GMT
Content-Length: 0
web.confg has below:
<bindings>
<wsHttpBinding>
<binding name="wsUserName" maxReceivedMessageSize="262144" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00">
<security mode="Transport">
<!--<message clientCredentialType="UserName" negotiateServiceCredential="false" establishSecurityContext="false" />-->
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="Example.SampleService.SampleService">
<host>
<baseAddresses>
<add baseAddress="http://localhost/Example.SampleService/" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsUserName" contract="Example.IVaultService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!--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"/>
<serviceCredentials useIdentityConfiguration="true">
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>

To import your service into SoapUI you need WSDL description.
To get it use one of the following URI:
http://localhost/Example.SampleService/SampleService.svc?singleWsdl
or http://localhost/Example.SampleService/SampleService.svc?wsdl
Before you must enable publishing of metadata.
<serviceBehaviors>
<behavior name="GlobalBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
add to your service behaviorConfiguration="GlobalBehavior"

Related

WCF SSL Service giving 404 not found

I keep getting a 404 error for my WCF service over SSL. Without SSL it works fine. I can access the service directly in the browser and set a web reference to it fine. In Fiddler it gives an "There was no channel actively listening at end point" error and here is the web.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="Inventory.Product.ProductDataAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</webHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="Inventory.Product.ProductData"
behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="webHttpBinding"
behaviorConfiguration="Inventory.Product.ProductDataAspNetAjaxBehavior"
contract="Inventory.Product.ProductData" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding"
address="mex" />
</service>
</services>
</system.serviceModel>
Ok, I found the answer at WCF over SSL - 404 error. I had forgot to set the binding configuration - when I did that, it worked.

Unable to add service reference

I am unable to connect to a WCF service hosted on our dev server but I am able to browse to it.
I am just trying to add a service reference via Visual Studio and when I click on Go, it gives me the following error.
An error occurred while receiving the HTTP response to http://...Service.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
My other colleagues are able to add the service reference and connect to this service with no issues, which makes it harder for me to understand the cause of this issue.
Web.config - system.serviceModel:
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding" maxReceivedMessageSize="2147483646">
<readerQuotas maxStringContentLength="2147483646" />
<security mode="None">
<!-- **WARNING** Changes to the security binding must also be made in client binding code -->
<transport clientCredentialType="None" proxyCredentialType="None" />
<message clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="X.X.X.RepositoryService" behaviorConfiguration="repositoryServiceBehavior">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding"
contract="X.X.X.ICatalogServiceContract" />
<!-- ** NOTE Metadata not supported SSL at this time **-->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="repositoryServiceBehavior">
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</serviceBehaviors>
</behaviors>

404 when trying to access WCF service

I am just getting started with WCF and am having a bit of trouble getting my message encryption to work. I finally got Role based authentication working with Asp.Net Identity 2.0 and am now trying to secure all data exchanged with encryption. I have signed my own x.509 certificate using SelfCert. Now when I try to hit any method on my contract I get a 404. I think the problem might be somewhere in my web.configs. Can anyone point out any obvious noobie mistakes in these web.config files?
Service Config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="authBehavior">
<serviceCredentials>
<serviceCertificate findValue="onpSquad"
storeLocation="LocalMachine"
storeName="My"
x509FindType="FindBySubjectName"/>
<clientCertificate>
<authentication certificateValidationMode="None" />
</clientCertificate>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WCFServiceWebRole1.Onp.Security.IdentityValidator,WCFServiceWebRole1" />
</serviceCredentials>
<serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="WCFServiceWebRole1.Onp.Security.RoleAuthorizationManager,WCFServiceWebRole1">
</serviceAuthorization>
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false 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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="authBehavior" name="WCFServiceWebRole1.SupportTicketSubmission">
<endpoint address="SupportTicketSubmission.svc"
binding="wsHttpBinding"
bindingConfiguration="MessageAndUserName"
name="SecuredByTransportEndpoint"
contract="WCFServiceWebRole1.Onp.IServiceSquadContract" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="MessageAndUserName">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
The client
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IServiceSupportTicketSubmission" />
<binding name="BasicHttpBinding_IServiceLoggingContract" />
</basicHttpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1" />
<binding name="WSHttpBinding_IServiceSquadContract">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:64054/Service1.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
name="WSHttpBinding_IService1">
<identity>
<userPrincipalName value="MARIASCOMPUTER\chuyita" />
</identity>
</endpoint>
<endpoint address="http://localhost:10234/SupportTicketSubmission.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServiceSupportTicketSubmission"
contract="OnpService.IServiceSupportTicketSubmission" name="BasicHttpBinding_IServiceSupportTicketSubmission" />
<endpoint address="http://localhost:10234/SupportTicketSubmission.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IServiceSquadContract"
contract="OnpService.IServiceSquadContract"
name="SecuredByTransportEndpoint">
<identity>
<dns value ="onpSquad" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Old config file
As you can see from below, there were never any explicit endpoints defined. This is the first time I actually have to define them so that I can use ASP.Net's Identity 2.0 for logging in and also setting up encryption.
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false 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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
Update thus far
I got a WCF book and read the first chapter. I've got my binding working correctly and I am able to access the methods of my ISquadContract but now am having issues with Identity 2.0 not grabbing the provided username from the request. That's a topic for another question. Here is what my new config looks like
<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="wsHttpBinding"/>
</protocolMapping>
<services>
<service name="WCFServiceWebRole1.SupportTicketSubmission"
behaviorConfiguration="authBehavior"
>
<endpoint address="SupportTicketSubmission.svc"
binding="wsHttpBinding"
contract="WCFServiceWebRole1.Onp.IServiceSquadContract"
bindingConfiguration="squadBindingConfiguration">
</endpoint>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="authBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WCFServiceWebRole1.Onp.Security.IdentityValidator,WCFServiceWebRole1" />
</serviceCredentials>
<serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="WCFServiceWebRole1.Onp.Security.RoleAuthorizationManager,WCFServiceWebRole1">
</serviceAuthorization>
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false 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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<wsHttpBinding>
<binding name="squadBindingConfiguration">
<security mode="None">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
Your client configuration file appears to define config to allow it to connect to three distinct service endpoints, one available at the address:
http://localhost:64054/Service1.svc
which is expecting to find there a service which exposes a contract called:
ServiceReference1.IService1
and the other two available at the address:
http://localhost:10234/SupportTicketSubmission.svc
however, one of these is expecting to call the service contract called:
OnpService.IServiceSupportTicketSubmission
and the other one is expecting to call the service contract called:
OnpService.IServiceSquadContract
Your service configuration file, on the other hand, defines a service endpoint available at the base service address of:
SupportTicketSubmission.svc
and exposing the contract:
WCFServiceWebRole1.Onp.IServiceSquadContract
This is about as confused a picture I think I have ever seen in two WCF config files which are supposed to work together. There are multiple problems here. If you want me to help you detangle this, write me a comment below.

wcf with basic authentication through reverse proxy

I have a Web Service which uses basic authentication with ssl through a reverse proxy. It has already cost me quite some time to figure out how to get this working and I still fail to get it fully working.
if you type in the url in the browser https://domain.com/service.svc, it asks for credentials and if correct, you get the overview page of the service.
So that seems to be okay.
But when I try to add the Service to Visual Studio 2010, I get the following error:
Metadata contains a reference that cannot be resolved:
The document format is not recognized (the content type is 'text/html; charset=utf-8').
Metadata contains a reference that cannot be resolved: 'https://domain.com/service.svc'.
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm=NTLM'.
The remote server returned an error: (401) Unauthorized.
If the service is defined in the current solution, try building the solution and adding the service reference again.
Here is my web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyBinding">
<!--<httpsTransport authenticationScheme="Basic"/>-->
<security mode="TransportCredentialOnly">
<transport clientCredentialType="None" proxyCredentialType="Basic" realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="WcfService1.PortalService" behaviorConfiguration="NorthwindBehavior">
<host>
<baseAddresses>
<add baseAddress="https://domain.com/" />
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBinding" contract="WcfService1.IPortalService">
<!--<identity>
<servicePrincipalName value=""/>
</identity>-->
</endpoint>
<!--<endpoint address="mex" binding="basicHttpBinding" bindingConfiguration="MyBinding" name="mex" contract="WcfService1.IPortalService"></endpoint>-->
</service>
</services>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="https://domain.com/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<!--<extensions>
<bindingElementExtensions>
<add name="httpsViaProxyTransport" type="WcfService1.HttpsViaProxyTransportElement, WcfService1"/>
</bindingElementExtensions>
</extensions>
<bindings>
<customBinding>
<binding name="UserNamePasswordSecured">
<textMessageEncoding />
<security authenticationMode="UserNameOverTransport" />
<httpsViaProxyTransport />
</binding>
</customBinding>
</bindings>-->
<behaviors>
<serviceBehaviors>
<behavior name="NorthwindBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceAuthorization principalPermissionMode="UseAspNetRoles"/>
<serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="MembershipProvider"/></serviceCredentials>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SampleEndpointBehavior">
<!--<wsdlExtensions location="http://domain.com/PortalService.svc" singleFile="true"/> -->
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
I tried numerous things like following this post: http://blog.hackedbrain.com/2006/09/26/how-to-ssl-passthrough-with-wcf-or-transportwithmessagecredential-over-plain-http/ but not very succesful.
I also tried to add site bindings to http because the wsdl is generating the server name instead of the domain name, so maybe there is something wrong at that end as well...
So hopefully someone can provide me with some pointers!
Note that the web.config file has some 'junk' in it because of trying with million different settings...

WCF net.tcp connection always fails

I tried to setup a service for testing using a net.tcp binding. I also set a http endpoint. The configuration is as follows:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="Inbound_REST">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="InboundHttpConfiguration">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="InboundTcpConfiguration">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="InboundTcpConfiguration" name="Inbound">
<endpoint address="" binding="netTcpBinding" contract="IContract">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:6969/Inbound" />
</baseAddresses>
</host>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<client>
<endpoint name="httpEndPoint" address="http://localhost:1568/Inbound.svc" binding="basicHttpBinding" contract="IContract" />
<endpoint name="tcpEndPoint" address="net.tcp://localhost:6969/Inbound" binding="netTcpBinding" contract="IContract" />
</client>
<bindings>
<basicHttpBinding>
<binding name="httpbind">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
<netTcpBinding>
<binding name="tcpbind">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
When I attempt to consume the service using the net.tcp binding, it always return me the error:
Could not connect to net.tcp://localhost:6969/Inbound. The connection attempt lasted for a time span of 00:00:00.9531494. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:6969.
By the way, the http binding works fine. I think it could be some machine configuration, but wasn't able to find what's the root cause.
If you are trying to run your WCF service through visual studio netTcpBinding is not supported. Sorry!
Check out this post for a more detailed explanation.
Why did you leave out the ".svc" for the net.tcp address for the client? Maybe it should be "net.tcp://localhost:6969/Inbound.svc"
What hosting you are using..IIS7 or console or others?
1)Check all tcp services are running in services.msc
2)Turn off your fire wall or add firewall exception to your tcp port
if you are hosting in iis7 check this link
IIS7 support for non http protocols