I am trying to include two endpoints in my WCF web based service - wsHttp and netTcp.
As shown in the Web.config below I have added them, but receive the following error when when I compile and click on Service.svc in my web browser:
Error page:
Server Error in '/MyService' Application. Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The binding at system.serviceModel/bindings/wsHttpBinding does not have a configured binding named 'wsHttpBinding'. This is an invalid value for bindingConfiguration.
Source Error:
Line 16: </baseAddresses> Line 17: </host> Line 18: <endpoint address="http://localhost:8090/Services/MyService" Line 19: binding="wsHttpBinding" Line 20: bindingConfiguration="wsHttpBinding"
Source File: C:\MyService\web.config Line: 18
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
Web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="wsHttpBinding"/>
</protocolMapping>
<services>
<service
name="Microsoft.ServiceModel.Samples.MyService">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9001/"/>
</baseAddresses>
</host>
<endpoint address="http://localhost:8090/Services/MyService"
binding="wsHttpBinding"
bindingConfiguration="wsHttpBinding"
name="MyService_WsHttp"
contract="Microsoft.ServiceModel.Samples.IService" />
<endpoint address="net.tcp://localhost:9000/Services/MyService"
binding="netTcpBinding"
bindingConfiguration="tcpBinding"
name="MyService_Tcp"
contract="Microsoft.ServiceModel.Samples.IService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
take this out:
bindingConfiguration="wsHttpBinding"
from here:
address="http://localhost:8090/Services/MyService"
binding="wsHttpBinding"
bindingConfiguration="wsHttpBinding"
I don't thing that you have properly answer the question I'am sure he want to implement the
a binding configuration so instead of removing bindingConfiguration="wsHttpBinding, just make sure that the binding in your and point match the one in your configure file.
Hope this will work
e.g:
<bindings>
<netTcpBinding>
<!--Configure the Service operation instance object timeout of an endpoint -->
<binding name="netTCP" receiveTimeout="00:00:10" />
</netTcpBinding>
</bindings>
<endpoint address="PerSessionService" binding="netTcpBinding" contract="InstanceContext_PerSessionService.IPerSessionService" bindingConfiguration="netTCP">
Related
I have created a IDummyService contract implemented by DummyService. I am trying to self-host this service using the following configuration:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<services>
<service name="DummyService.DummyService" behaviorConfiguration="MEX">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/" />
</baseAddresses>
</host>
<endpoint address="DummyService"
binding="basicHttpBinding"
contract="DummyService.IDummyService"/>
<endpoint address="net.tcp://localhost:8734/DummyService/"
binding="netTcpBinding"
bindingConfiguration = "TransactionalTCP"
contract="DummyService.IDummyService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name = "TransactionalTCP" transactionFlow = "true"/>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name = "MEX">
<serviceMetadata/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
The Service Host code that runs fine and starts these endpoints. However, when I try to access the following endpoints I get error as Page isn't working in Chrome browser.
http://localhost:8733/DummyService/
http://localhost:8733/mex/
However, I can access the page http://localhost:8733/
I don't understand why is that.
I thought the endpoint address is address entry for that endpoint appended to host's baseaddress
Any ideas what I am doing wrong ?
Thanks.
You have applied the attribute behaviorConfiguration="MEX" but didnt make use of it,you need to enable the metadata discovery which is false by default in WCF for security reasons.
<serviceBehaviors>
<behavior name = "MEX">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
Now when you browse the http://localhost:8733/DummyService/ and http://localhost:8733/mex/ ,a blank page will be displayed in the browser,instead of default error page.
And also if you want to test the net.tcp endpoint you can use WCFtestclient.exe.
I getting this error :An unhandled exception of type 'System.ServiceModel.CommunicationException'
full discripton of error:
An unhandled exception of type
'System.ServiceModel.CommunicationException' occurred in mscorlib.dll
Additional information: An error occurred while receiving the HTTP
response to
http://localhost:8733/Design_Time_Addresses/SnUpdateService/Service1/.
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.
When in clien i am trying to get response with stream data
SnUpdateService.Service1Client SnService = new SnUpdateService.Service1Client();
SnUpdateService.UpdateFiles com = new SnUpdateService.UpdateFiles();
com.Path = "C:\\temp";
com.SearchType = 1;
com.Version = "20150101";
SnUpdateService.UpdateFiles comReturn = new SnUpdateService.UpdateFiles();
comReturn = SnService.GetUpdateFiles(com);//here error
if there is no stream data all work fine.
What i am doing wrong?
This my client config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxBufferPoolSize="200000000"
maxReceivedMessageSize="200000000" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8733/Design_Time_Addresses/SnUpdateService/Service1/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="SnUpdateService.IService1" name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
This my server webConfig
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="SnUpdateService.Service1">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8733/Design_Time_Addresses/SnUpdateService/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="basicHttpBinding" contract="SnUpdateService.IService1">
<!--
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>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" 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" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I think you are missing the definition for the binding configuration BasicHttpBinding_IService1 in client configuration file.
Also, you can set includeExceptionDetailInFaults="False" to "true" to get more detailed stack trace. Which helps you debug.
I had the same problem some time back and resolved it by enabling 32-Bit applications in the app pool where my service was hosted.
<ServiceContract()>
Public Interface IService1
<OperationContract()>
<WebInvoke(Method:="POST", UriTemplate:="InsertData/{name}/{Surname}")>
Function InsertData(ByVal name As String, ByVal surname As String) As String
End Interface
Implemented it
Public Class Service1
Implements IService1
Public Function InsertData(name As String, surname As String) As String Implements IService1.InsertData
' Save name and surname which does work
End Function
End Class
My web.config
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="WcfParameters.Service1">
<endpoint address="http://localhost:12345/Service1.svc" behaviorConfiguration="webHttpBinding"
binding="webHttpBinding" bindingConfiguration="" name="WebHttpw"
contract="WcfParameters.IService1" />
<!--<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />-->
</service>
</services>
<client>
<endpoint address="http://localhost:12345/Service1.svc" binding="webHttpBinding"
bindingConfiguration="" contract="WcfParameters.IService1" />
</client>
<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"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttpBinding">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<!--<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>-->
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
I am trying to create a service which will accept a few parameters and save the data to my database.
Using the above configuration if i navigate to http://localhost:12345/Service1.svc/InsertData/name/surname i get the error "Method Not Found"
If i do the same POST method and run it in Fiddler then it saves to the database successfully.
I then used this link http://blogs.msdn.com/b/carlosfigueira/archive/2012/03/26/mixing-add-service-reference-and-wcf-web-http-a-k-a-rest-endpoint-does-not-work.aspx as a guide but i think ive used as much info in order to accomplish what i think i need (i could be wrong).
Should i be doing something different?
Using the above configuration if i navigate to
http://localhost:12345/Service1.svc/InsertData/name/surname i get the
error "Method Not Found"
When you do this trough your browser you are actually doing a GET request, which your method does not support.
When you do it trough Fiddler you issue a POST.
You can do a POST using the WebRequest class or HttpRequest trough your code.
I have a webservice which I can get to run on my computer, but when deployed to a webserver (in a DMZ) it doesn't work.
When running the service on the web server, it shows a WSDL and singleWSDL that seemingly appear to be correct. Using the singleWSDL in SoapUI to test the service returns the following error message
The message could not be processed. This is most likely because the
action 'http://tempuri.org/IService1/TestStringContract' is incorrect
or because the message contains an invalid or expired security context
token or because there is a mismatch between bindings. The security
context token would be invalid if the service aborted the channel due
to inactivity. To prevent the service from aborting idle sessions
prematurely increase the Receive timeout on the service endpoint's
binding.
From what I gather, the most likely cause, is an issue in the App.Config file, which I have detailed herein
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="MyService.Service1" behaviorConfiguration="MyService.Service1Behavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:{port}/MyService.Service1.svc" />
</baseAddresses>
</host>
<endpoint address="http://{external_ip}:{port}/MyService.Service1.svc" binding="wsHttpBinding" contract="MyService.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="EquitaWcfCbl.Service1Behavior">
<serviceThrottling maxConcurrentCalls="10"/>
<serviceMetadata httpGetEnabled="True" httpGetUrl="http://{external_ip}:{port}/EquitaWcfCblMyService.Service1.svc/mex"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
[update # 2014-02-19 1400hrs]
With further research continually pointing that the setup of the App.Config; I decided to pull out the current App.Config file and start it again, from scratch, using the WCF Service Configuration Editor, which is built into Visual Studio (tools menu) adding in the information a piece at a time and testing progress, which resulted in a working service with the following App.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior1">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata
httpGetEnabled="true"
httpGetUrl=" http://{externalip}:{port}/MyService.Service1.svc/mex"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding>
<security mode="None"></security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service
behaviorConfiguration="ServiceBehavior1"
name="EquitaWcfCbl.TabletService">
<endpoint
address="http://{externalip}:{port}/MyService.Service1.svc/mex"
binding="basicHttpBinding"
bindingConfiguration=""
name="ServiceEndpoint1"
contract=" MyService.Service1" />
</service>
</services>
</system.serviceModel>
</configuration>
I'm not (yet) entirely convinced that this is exactly what we need, but with a working service ... I can at least progress.
When I pass a list of objects out of my silverlight app using WCF everything works fine until the List grows too big. It seems that when I exceed 80 items I get the error:
The remote server returned an unexpected response: (404) Not Found
I'm presuming that it's because the List has grown too big as when the List had 70 items everyhing works fine. Strange error message though, right?
In the config file I change the maxBufferSize to the highest value that it will accept but still I can't have more then 80 items in my List.
How can I pass out large objects without having to split the object up?
Thanks Shawn, so where exactly do I do it?
This is my ServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<client>
<!--"http://sy01911.fw.gsjbw.com/WcfService1/Service1.svc"-->
<endpoint address="http://localhost/WcfService1/Service1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService11"
contract="SilverlightApplication1.ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxBufferSize="655360000"
maxReceivedMessageSize="655360000">
<security mode="None" />
</binding>
<binding name="BasicHttpBinding_IService11" maxBufferSize="655360000"
maxReceivedMessageSize="655360000">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
and this is the server config that you mentioned
<services>
<service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior" >
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" >
<!--
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>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
If you are sending out a large number of items from WCF, also make sure that maxItemsInObjectGraph is a relatively high number
<behaviors>
<serviceBehaviors>
<behavior name="YourBahvior">
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
</behavior>
</serviceBehaviors>
</behaviors>
There are two config files. The silverlight clientconfig will let you send the larger message, but if you'r eusing WCF, there is a server web.config that limits the size of the received message (to prevent DDOS attacks).
In server side, change the config file to make the service can accept large message.
Add a basicHttpBinding configuration in <system.serviceModel> section:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyBasicHttpBinding" maxReceivedMessageSize="300000000">
<security mode="None"/>
<readerQuotas maxStringContentLength="300000000"/>
</binding>
</basicHttpBinding>
</bindings>
.......
Add the configuration to the service binding.
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBinding" contract="WcfService1.IService1">