Trying to add includeExceptionDetailInFaults="true" to web config for web service that I am calling but none of two behaviors that I have defined are working.
This is the error I get when calling web service:
System.ServiceModel.FaultException: The server was unable to process
the request due to an internal error. For more information about the
error, either turn on IncludeExceptionDetailInFaults (either from
ServiceBehaviorAttribute or from the configuration behavior) on the
server in order to send the exception information back to the client,
or turn on tracing as per the Microsoft .NET Framework 3.0 SDK
documentation and inspect the server trace logs.
<behaviors>
<serviceBehaviors>
<behavior name="debug">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<!--<behaviors>
<endpointBehaviors>
<behavior name="debug">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</endpointBehaviors>
</behaviors>-->
<client>
<endpoint address="..."
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_ICommunicationService"
behaviorConfiguration="debug"
contract="CommunicationServiceReference.ICommunicationService"
name="WSHttpBinding_ICommunicationService" />
</client>
EDIT:
I looked at this similar question, but in suggested answer there is
<services>
<service...
while in my case it's
<client>
<endpoint
I also tried changing to services but that didn't work
I think you're including the attribute at the wrong end, basically you're telling the client to include exception information (which would be a security risk).
In the service web.config you will have a section for behaviours (this is taken from our code which is working fine and has done for about 4 years):
<system.serviceModel>
<bindings configSource="bindings.config"></bindings>
<client configSource="client-local.config"></client>
<behaviors configSource="behaviors.config"></behaviors>
<services>
<service name="xxx.SomeService">
<endpoint contract="xxx.ISomeService" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding"/>
</service>
</system.serviceModel>
Behaviours.config looks like this:
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
</behavior>
</serviceBehaviors>
</behaviors>
Also, by externalising the config we can keep one copy in a _MasterConfigs folder that is copied to the services at build time which ensures consistency across all projects.
EDIT:
Apologies... I just re-read your question and you've basically got what I've outlined. Perhaps the fact you're naming the behaviour is causing the problem (not that it logically should). Unless it's a publicly exposed WCF I think it best to return exception information anyway, even in release, for logging.
Related
Our client is getting below error when they try to call the web service via HTTPS request.
'There was no endpoint listening at https://XXXXXX/XXXX.svc - The remote server returned an error: (403) Forbidden.'
But the interesting part is, client successfully connects using the port which was used by the previous version. But new ports are not working. which means still client can call the new service using the old port. But once we change the bindings to the new https port, client is getting above error.
Below checks have been completed already.
1) Client can successfully access the URL from their server.
2) No firewall rules placed for the newly created port.
2) SSL root certificates are placed in the Trusted Root Certification folder.
Please let me know if you have any idea regarding this issue?
Thank you
According to your description, it seems that you may missed the https setting in the wcf application web.config file.
The following is a complete example of a web.config file for a WCF service using HTTPs.
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="MySecureWCFService.Service1">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="secureHttpBinding"
contract="MySecureWCFService.IService1"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata 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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
More details, you could refer to this article.
Thank you for your time all.
Proxy Server was blocking the requests come through the specific ports. Issue has been resolved after adding the ports into the proxy server.
I am trying to access a method within my wcf service through a url. I have followed many guides on how to hook up REST with wcf and access a method through a get. I get the following error
Content Type application/soap+xml; charset=utf-8 was not supported by service.
I know this has to do with my web.config being incorrect however, I have matched my service behavior configuration correctly. What am I missing here? Any help would be much appreciated.
<system.serviceModel>
<services>
<service name="Developer1.Core.Service.Developer1Service"
behaviorConfiguration="MyServiceBehavior" >
<endpoint
address="ws"
binding="wsHttpBinding"
contract="Developer1.Core.ServiceContracts.IDeveloper1Service" />
<endpoint
address="" behaviorConfiguration="webBehavior"
binding="webHttpBinding"
contract="Developer1.Core.ServiceContracts.IDeveloper1Service" />
<endpoint
address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Seems the error occurs after I have added behavior name="MyServiceBehavior".
This is what I am trying to accomplish Making a WCF Web Service work with GET requests
SOLVED!!!
I solved the issue seems I had to do what i was doing within a service library instead of an application. So now I am handling REST with my wcf Library and the other methods are handled within my WCF Application. Seems app config and web config differ in a way. Then I went to solution properties and selected to start multiple projects at once. Now i can hit methods with get requests within the library and the application runs all the other methods that arent dealing with HTTP protocal. My solution has a WCF Library and WCF Application within it. The Application uses web.config and the library uses app.config. following this article http://weblogs.asp.net/kiyoshi/wcf-using-webhttpbinding-for-rest-services works with the App config. My WCF application then inherits from my service file within my Library and does not contain any extra service methods, it just runs the methods within my WCF Library. But the Library is set up to handle HTTP requests. Probably not the correct solution but it works for me.
I am trying to hook up one of my methods to be called after a get request is sent to the appropriate endpoint. When tampering with my web.config, I assigned a name to my behavior and i get the following error.
'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
Not sure why just assigning an attribute to my behavior throws this error.
<system.serviceModel>
<services>
<service name="Developer1.Core.Service.Developer1Service"
bindingConfiguration="myConfiguration" >
<endpoint
address="" behaviorConfiguration="webBehavior"
binding="webHttpBinding"
contract="Developer1.Core.ServiceContracts.IDeveloper1Service" />
<endpoint
address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="myConfiguration">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Seems when i take away and don't have the name attribute, the error goes away. Any thoughts?
SOLVED!!!
I solved the issue seems I had to do what i was doing within a service library instead of an application. So now I am handling REST with my wcf Library and the other methods are handled within my WCF Application. Seems app config and web config differ in a way. Then I went to solution properties and selected to start multiple projects at once. Now i can hit methods with get requests within the library and the application runs all the other methods that arent dealing with HTTP protocal. My solution has a WCF Library and WCF Application within it. The Application uses web.config and the library uses app.config. following this article http://weblogs.asp.net/kiyoshi/wcf-using-webhttpbinding-for-rest-services works with the App config. My WCF application then inherits from my service file within my Library and does not contain any extra service methods, it just runs the methods within my WCF Library. But the Library is set up to handle HTTP requests. Probably not the correct solution but it works for me.
You defined myConfiguration as bindingConfiguration for the service. But you do not have binding configurations at all. You defined service behavior with this name. It has nothing to do with binding.
I have built an http based web service application with WCF and everything works. Now I try to convert it to run over https instead, but I can’t get it to work properly. I only receive "Bad Request". Currently this web service is running on IIS 7.5 and .NET 4.5. Anyone knows what i shall do to convert it from http to https and what I shall change on client side to be able to request an https web service instead of http.
Thx in advanced!
For Services Configuration use this
<services>
<service behaviorConfiguration="webServiceClientBehavior" name="My.Service.ServiceName">
<endpoint address="http://localhost/WCFClient" binding="basicHttpBinding" bindingConfiguration="secureBinding" contract="My.Service.IServiceName"/>
</service>
For Binding Configuration use below
<bindings>
<basicHttpBinding>
<binding name="secureBinding">
<security mode="Transport" />
</binding>
</basicHttpBinding>
For behavior configuration use below
<serviceBehaviors>
<behavior name="webServiceClientBehavior">
<!--For MetaData-->
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost/WCFClientMD"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
I am creating a event handler in MS Project Server. This event handler is calling a class library (dll file). The event handler is set and triggered from within the MS Project by clicks and not by code. In this class library, I am having a service reference to a web service. But, whenever, the event is triggered, I see the following error when I debug the class library via 'Attach to Process' option:
Could not find default endpoint element that references contract 'PSS.Project.ProjectSoap' 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.
Here is what my app.config looks like:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="basicHttpBehavior">
<clientCredentials>
<windows allowedImpersonationLevel="Impersonation" />
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttpConf" sendTimeout="01:00:00" maxBufferSize="500000000"
maxReceivedMessageSize="500000000">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="500000000" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="ProjectSoap">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://xxxx/pwa/_vti_bin/PSI/ProjectServer.svc"
behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding"
bindingConfiguration="basicHttpConf" contract="SvcProject.Project"
name="basicHttp_Project" />
<endpoint address="http://xxxx/pwa/_vti_bin/PSI/ProjectServer.svc"
behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding"
bindingConfiguration="basicHttpConf" contract="SvcResource.Resource"
name="basicHttp_Resource" />
<endpoint address="http://xxxx/pwa/_vti_bin/PSI/ProjectServer.svc"
behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding"
bindingConfiguration="basicHttpConf" contract="SvcStatusing.Statusing"
name="basicHttp_Statusing" />
<endpoint address="http://xxxx/pwa/_vti_bin/PSI/Project.asmx?wsdl"
binding="basicHttpBinding" bindingConfiguration="ProjectSoap"
contract="PSS.Project.ProjectSoap" name="ProjectSoap" />
</client>
</system.serviceModel>
</configuration>
I also confirmed that the URL: http://xxxx/pwa/_vti_bin/PSI/Project.asmx?wsdl is working.
In the cs file, the error appears on the following code:
ProjectSoapClient projectSvc = new ProjectSoapClient();
When I do the same thing in a console app, it works, but when use a class library, it fails. I have read some Q&A's here and I know that when I am calling a service reference from a class library, I need to include configuration files of the service reference into the the class library, but I am not quite sure how and where to bring the config files from in my case and what portion of app.config should I add it to.
I have been able to call a WCF service within a Project Server Event Receiver DLL.
In order to do so, please follow these "tricks":
1.- For configuracion purposes, the DLL's (you code) execute within the Microsoft.Office.Project.Server.Eventing.exe process, which is located (in a default configuration) on: "C:\Program Files\Microsoft Office Servers\14.0\Bin". For custom installs open the task manager and right click the "Microsoft.Office.Project.Server.Eventing.exe" and select go to file. So, any configuration you need to be written in a file needs to be put in that directory insede the file: "Microsoft.Office.Project.Server.Eventing.exe.config". I have used this file to put a Database Connection String and I've been able to read it with the System.Configuration library. However, not all configuration sections works, I tried to put appSettings and a Sharepoint error was raised.
2.- For interaction with the Project Servers PSI, please use the WCF interface instead of the ASMX interface (I don't know why, but it works much better). I suggest using WCF programmatically (a quick search on google will net you how to set the bindings on the code).
I hope this helps you, I assure you it works. Now I'm trying to call ASMX service within the DLL (I'm still on it, if I find something I'll post).