I have a WCF service nested in an ASP.NET 4.5 web application and everything was running without issue until I attempted to specify a port. I have to run on a separate port as per my client's requirements but I cannot figure out what I am doing wrong.
For now I am running everything local and I did punch holes in my firewall so I know that is not the issue. The error I get - System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:59031 - tells me that I have no listener attached so, again, it must be my config. Right?
Here is a call:
http://localhost:59031/seoland/seo.svc/Login?User=test&Pass=pass
And here is my config:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
<services>
<service name="seoland.extranet.seo">
<endpoint address="" behaviorConfiguration="json" binding="webHttpBinding" name="MainHttpPoint" contract="seoland.extranet.seo">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" name="MexEP" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:59031/seoland/seo.svc"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<webHttpBinding>
<binding openTimeout="00:10:00" sendTimeout="00:10:00" useDefaultWebProxy="false">
<readerQuotas maxDepth="32" maxStringContentLength="2048000" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="json">
<webHttp helpEnabled="false" automaticFormatSelectionEnabled="false" defaultBodyStyle="Bare"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding" httpGetBindingConfiguration=""/>
<serviceDebug httpHelpPageEnabled="false" httpsHelpPageEnabled="false" includeExceptionDetailInFaults="true"/>
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="http" port="59031"/>
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Again everything worked until I tried adding the port number - can somebody please help me out?
Thanks!
Are you using the correct port number? Also, make sure that there is no firewall restrictions and the port is open.
Related
I have a .NET project that I have inherited, in which I'm having issues getting a service to return properly when running on Windows Server IIS.
The ExceptionType is System.NullReferenceException
The Stacktrace is at Integra.HLX.SB.Web.WS_Reps..ctor() at CreateIntegra.HLX.SB.Web.WS_Reps() at System.ServiceModel.InstanceContext.GetServiceInstance(Message message) at System.ServiceModel.Dispatcher.InstanceBehavior.EnsureServiceInstance(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
This error gets thrown when I attempt to POST to the service's endpoint. I'm assuming I'm missing something within the web.config to allow this to work on IIS from a Windows Server, or maybe missing a feature setting within IIS on Windows Server.
Here is the relevant web.config settings...
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<webHttpBinding>
<binding name="binding1">
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="Integra.HLX.SB.Web.WS_RepsAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="Integra.HLX.SB.Web.WS_ClientContactsAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="Integra.HLX.SB.Web.WS_ContactUniverseNameAddressesAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="Integra.HLX.SB.Web.WS_UsersAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="jsonBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="RESTbehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Integra.HLX.SB.Web.WS_Reps">
<endpoint address="" behaviorConfiguration="Integra.HLX.SB.Web.WS_RepsAspNetAjaxBehavior" bindingConfiguration="binding1" binding="webHttpBinding" contract="Integra.HLX.SB.Web.WS_Reps" />
</service>
<service name="Integra.HLX.SB.Web.WS_ClientContacts">
<endpoint address="" behaviorConfiguration="Integra.HLX.SB.Web.WS_ClientContactsAspNetAjaxBehavior" bindingConfiguration="binding1" binding="webHttpBinding" contract="Integra.HLX.SB.Web.WS_ClientContacts" />
</service>
<service name="Integra.HLX.SB.Web.WS_ContactUniverseNameAddresses">
<endpoint address="" behaviorConfiguration="Integra.HLX.SB.Web.WS_ContactUniverseNameAddressesAspNetAjaxBehavior" bindingConfiguration="binding1" binding="webHttpBinding" contract="Integra.HLX.SB.Web.WS_ContactUniverseNameAddresses" />
</service>
<service name="Integra.HLX.SB.Web.WS_Users">
<endpoint address="" behaviorConfiguration="Integra.HLX.SB.Web.WS_UsersAspNetAjaxBehavior" bindingConfiguration="binding1" binding="webHttpBinding" contract="Integra.HLX.SB.Web.WS_Users" />
</service>
<service name="Integra.HLX.SB.Web.WS_SpeakerDataFeed" behaviorConfiguration="RESTbehavior">
<endpoint address="" bindingConfiguration="binding1" binding="webHttpBinding" behaviorConfiguration="jsonBehavior" contract="Integra.HLX.SB.Web.IWS_SpeakerDataFeed" />
</service>
<service name="Integra.HLX.SB.Web.WS_DashboardDataFeed" behaviorConfiguration="RESTbehavior">
<endpoint address="" bindingConfiguration="binding1" binding="webHttpBinding" behaviorConfiguration="jsonBehavior" contract="Integra.HLX.SB.Web.IWS_DashboardDataFeed" />
</service>
</services>
</system.serviceModel>
Any help would be appreciated. Thanks!
I was able to answer my own question. The fix for me in this instance was the web.config on the production server was missing the line <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
I found out more information by checking the Windows Event Viewer logs and found this key bit of information The service cannot be activated because it requires ASP.NET compatibility.
After inserting the aforementioned line into the web.config and restarting the AppPool and server, the service started working properly. I hope this helps anybody in the future.
This service I can see the JSON data while calling methods through browser when hosted on our IIS server but after moving it to client's server.. I can't see the data from browser though I can see through WCF Test CLient only... where I'm going wrong.. Could you suggest what should be done.
<bindings>
<wsHttpBinding>
<binding name="LargeSettings" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600">
<readerQuotas maxDepth="32" maxStringContentLength="100000" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="mobserviceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<services>
<service name="clubconnect.mobservice" behaviorConfiguration="mobserviceBehavior">
<endpoint address="" binding="wsHttpBinding" contract="clubconnect.imobservice" bindingConfiguration="LargeSettings"/>
<endpoint address="ws" binding="webHttpBinding" contract="clubconnect.imobservice" behaviorConfiguration="WebBehavior">
<identity>
<dns value="http://domain"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
You need to add a base address in there:
<host>
<baseAddresses>
<add baseAddress="http://<URL to the .svc file>" />
</baseAddresses>
</host>
Then your relative address for your webHttpBinding endpoint "ws" will resolve to
http://<URL to the .svc file>/ws
I have one wcf service on this site http://wswob.somee.com/wobservice.svc
I try to consume that service with my winform app. This is the error I receive when I create an instant of the service
com.somee.wobservice.IwobserviceClient myservice = new com.somee.wobservice.IwobserviceClient();
error:
Could not find default endpoint element that references contract
'com.somee.wobservice.Iwobservice' in the ServiceModel client configuration section. This
might be because no configuration file was found for your application, or because no
endpoint element matching this contract could be found in the client element.
I searched and modified my app.config file:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="wobservice">
<clientVia />
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint
name="wobservice"
address="http://wswob.somee.com/wobservice.svc"
binding="webHttpBinding"
contract="com.somee.wobservice"
behaviorConfiguration="wobservice" />
</client>
</system.serviceModel>
</configuration>
And my web.config in wcf folder:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="Web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://wswob.somee.com/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<bindings>
<webHttpBinding>
<binding>
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
<add binding="basicHttpBinding" scheme="http"/>
</protocolMapping>
<services>
<service name="wobwcf.wobservice">
<endpoint address=""
binding="webHttpBinding"
behaviorConfiguration="Web"
contract="wobwcf.Iwobservice" />
</service>
</services>
</system.serviceModel>
I don't really sure which part I got wrong. My experience of wcf is just a week...
Copy system.serviceModel section from the app.config in your library project and put it in your web.config and refresh service reference. See also this answer. Could not find default endpoint element
Add "WSHttpBinding" end point in your WCF service web.config file like below
<endpoint address="web" behaviorConfiguration="jsonBehavior" binding="webHttpBinding" bindingConfiguration="webHttpBindingWithJsonP" contract="DataService.IDataService"/>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="DataService.IDataService" />
and in your app.config file write code like below
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IDataService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/pricedataservice/DataService.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IDataService" contract="DataService.IDataService"
name="WSHttpBinding_IDataService" />
</client>
I am sure this will fix your problem and below blog will help you to understand different type of binding in WCF service
http://www.dotnet-tricks.com/Tutorial/wcf/VE8a200713-Understanding-various-types-of-WCF-bindings.html
Add client definition in your client web.config file like below;
<system.serviceModel>
/////
<client>
<endpoint address="referencedurl"
binding="webHttpBinding" bindingConfiguration=""
contract="MemberService.IMemberService"
name="MemberServiceEndPoint"
behaviorConfiguration="Web">
</endpoint>
</client>
////
</system.serviceModel>
AND Service Reference Name must same as the Interfaces prefix. contract="ReferenceName.IMemberService"
Getting the following error when attempting to start a Windows service hosting a WCF service:
Could not find a base address that matches scheme net.msmq for the endpoint with binding NetMsmqBinding. Registered base address schemes are [http].
Works fine if I remove the netmsmq binding and use the basichttp binding. Config is as below:
<system.serviceModel>
<services>
<service name="ManageContactService.ManageContact" behaviorConfiguration="ContactServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8888/ManageContact/ContactService"/>
</baseAddresses>
</host>
<endpoint address="net.msmq//localhost/private/testqueue" binding="netMsmqBinding"
bindingConfiguration="MyMsmqBinding" contract="ManageContactService.IManageContact" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<netMsmqBinding>
<binding name="MyMsmqBinding">
<security mode="None"></security>
</binding>
</netMsmqBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ContactServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
You need a colon:
net.msmq://localhost/private/testqueue
I have SSL working for my SOAP endpoint.
But as soon as I enable my REST endpoint, it throws a fit:
Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [https].
My app.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="IIncreasedBufferSize" maxBufferSize="1024000"
maxReceivedMessageSize="1024000">
<readerQuotas maxArrayLength="1024000" />
<security mode ="Transport">
<transport clientCredentialType= "None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WCFBehaviourSSL"
name="IWCF.IService">
<endpoint name="soap" address="soap" binding="basicHttpBinding" bindingConfiguration="IIncreasedBufferSize"
contract="IWCF.IServices">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint name="rest"
address="rest"
binding="webHttpBinding"
contract="IWCF.IServices"
behaviorConfiguration="REST" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary2/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="REST">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="WCFBehaviourSSL">
<serviceMetadata httpGetEnabled="False" httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
I found this question: REST WCF Service Over SSL
But rest assured, None of the answers provided are of use.
I have certificates, and it does work with SSL using the SOAP end point. (when rest endpoint is commented out).
I was missing a WebHTTPBinding, that uses Transport security:
<webHttpBinding>
<binding name ="REST SSL">
<security mode ="Transport">
<transport clientCredentialType= "None" />
</security>
</binding>
</webHttpBinding>
. . .
<endpoint name="rest"
address="rest"
binding="webHttpBinding"
contract="IWCF.IServices"
behaviorConfiguration="REST"
bindingConfiguration="REST SSL"/>