I am having this problem since a week now and am unable to resolve this. I have looked at various posts but found nothing related to the problem.
I have a website and a WCF service inside the same website project. It was all working fine, but suddenly, the WCF service client is not able to receive a valid response from the service.
Error message:
ProtocolException occured
The content type text/html; charset=utf-8 of the response message does
not match the content type of the binding (text/xml; charset=utf-8).
If using a custom encoder, be sure that the IsContentTypeSupported
method is implemented properly. The first 1024 bytes of the response
were: '
Value cannot be null.Parameter name: input
body {font-family:"Verdana";font-weight:norma....
I don't understand what is this parameter input. How can I resolve this issue? The WCF service is accessible via browser using the endpoint mentioned in the web.config
Here is the code:
Code behind:
using (var client = new Agent4HomeWebsite.PhotosWebServiceRef.PhotosWebServiceClient())
{
var temp = client.GetImageObjects();
}
Web.config:
<configuration>
....
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IPhotosWebService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="http://localhost:49274/PhotosWebService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IPhotosWebService"
contract="PhotosWebServiceRef.IPhotosWebService"
name="BasicHttpBinding_IPhotosWebService" />
</client>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
Related
I've read lots of threads the last hours but I did not find a solution which is working for me :-(
So as already multiple other users I have problems calling a SVC-Webservice via SSL from my Windows Phone 7 application. On localhost it works fine. I've deployed the Webservice within my Webapplication. The service "MyService.svc" is in the root of the webapplication. On IIS I've only added HTTPS (from Startcom, using default Port 443) for this IP and made SSL required. I could open my web application and I could open the Webservice using any browser at http://mydomain.com/MyService.svc, from both server and local development machine. The page says I could call svcutil.exe https://mydomain.com/MyService.svc?wsdl. When I click on the link the data is display correct.
Now when I try to access it via WP7 app I always get the following error:
"There was no endpoint listening at https://mydomain.com/MyService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details."
And inner details say: "The remote server returned an error: NotFound."
Here is the important part of my web.config. I don't know whether this is all required, as said I've copied it from multiple threads but at least in IE it works fine:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehavior">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="1073741824" />
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="https" port="443" />
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyBehavior" name="MyNamespace.MyService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="HttpsBinding"
contract="MyNamespace.IMyService">
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="HttpsBinding">
<readerQuotas maxStringContentLength="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<!-- <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> -->
Many thanks!
I have a WCF service, which has a method with the following signature:
object GetCommand(Guid apiKey, SocialService service, string name, object argument);
The reason it's working with objects as both the return type and last argument, is because it should be possible to pass any type as argument and return any type.
Anyway, I'm passing an object, which contains the following property:
public byte[] Photo { get; set; }
To enable large messages, I'd like to start using Mtom, while I was previously using plain-text as MessageEncoding type.
Problem is, I want it to be backwards compatible, so current already-configures clients should keep using plain-text encoding, while new clients should be able to use Mtom via the web.config.
My question is: is it possible to keep using plain-text as MessageEncoding by default (existing clients) and offer Mtom encoding as well side-by-side?
I've tried some things with the configuration, like defining multiple endpoints with different binding-configurations, but I can't get it to work:
Server
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpTextBinding_SocialProxy" />
<binding name="BasicHttpMtomBinding_SocialProxy" maxReceivedMessageSize="5242880" messageEncoding="Mtom">
<readerQuotas maxStringContentLength="655360" maxArrayLength="1310720" maxNameTableCharCount="1310720" maxBytesPerRead="327680" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="SocialProxyService">
<endpoint name="BasicEndpoint_SocialProxy" address="" contract="InfoCaster.SocialProxy.ISocialProxy" binding="basicHttpBinding" bindingConfiguration="BasicHttpTextBinding_SocialProxy" />
<endpoint name="MtomEndpoint_SocialProxy" address="" contract="InfoCaster.SocialProxy.ISocialProxy" binding="basicHttpBinding" bindingConfiguration="BasicHttpMtomBinding_SocialProxy" />
</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="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Client
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_SocialProxy" messageEncoding="Mtom" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://socialproxy.local/socialproxy.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_SocialProxy"
contract="Webservice.SocialProxy" name="BasicHttpBinding_SocialProxy" />
</client>
</system.serviceModel>
Problem is:
If I don't set Mtom messageEncoding # the client, everything works via plain-text. But when I set it to use Mtom, I'll get an exception:
The remote server returned an error: (415) Cannot process the message because the content type 'multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:65a6b418-8eb3-4c76-b4c0-ea3486a56892+id=2";start-info="text/xml"' was not the expected type 'text/xml; charset=utf-8'..
Anyone able to help me out? :-)
If you want to add a new endpoint (for newer clients), that endpoint needs to be in a different address. Since you didn't get any error, I imagine you have an incorrect name in the name attribute of the <service> element. Remember that the name attribute should contain the fully-qualified name of the service class. If your service class is at the namespace InfoCaster.SocialProxy, your service configuration should be defined like below:
<services>
<service name="InfoCaster.SocialProxy.SocialProxyService">
<endpoint name="BasicEndpoint_SocialProxy" address="" contract="InfoCaster.SocialProxy.ISocialProxy" binding="basicHttpBinding" bindingConfiguration="BasicHttpTextBinding_SocialProxy" />
<endpoint name="MtomEndpoint_SocialProxy" address="newClients" contract="InfoCaster.SocialProxy.ISocialProxy" binding="basicHttpBinding" bindingConfiguration="BasicHttpMtomBinding_SocialProxy" />
</service>
</services>
And the clients would have something like
<client>
<endpoint address="http://socialproxy.local/socialproxy.svc/newClients"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_SocialProxy"
contract="Webservice.SocialProxy" name="BasicHttpBinding_SocialProxy" />
</client>
Now, if you want a single endpoint which can support both text and MTOM in a way that clients sending text receive a text response, and clients which send MTOM receive a MTOM response back, you can still do it. You'll need a custom encoder, and I wrote one in the post at http://blogs.msdn.com/b/carlosfigueira/archive/2011/02/16/using-mtom-in-a-wcf-custom-encoder.aspx.
hi i am tring to use this article for making my wcf service authenticate without SSL
http://webservices20.blogspot.in/2008/11/introducing-wcf-clearusernamebinding.html
but i am geting this error when i try to compile :
<system.serviceModel>
<extensions>
<bindingExtensions>
<add name="clearUsernameBinding" type="ClearUsernameCollectionElement, ClearUsernameBinding" />
</bindingExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyValidator,App_Code"/>
</serviceCredentials>
<!--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>
<behavior name="SampleServiceBehaviour">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="MyUserNameValidator, App_Code" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Service" behaviorConfiguration="SampleServiceBehaviour">
<endpoint address="~/QuadraService/Service.svc" binding="wsHttpBinding" contract="IService" bindingConfiguration="Binding1"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
<endpoint binding="clearUsernameBinding" bindingConfiguration="myClearUsernameBinding" contract="IService" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<bindings>
<clearUsernameBinding>
<binding name="myClearUsernameBinding"
messageVersion="Soap12">
</binding>
</clearUsernameBinding>
<wsHttpBinding>
<binding name="Binding1">
<!-- UsernameToken over Transport Security -->
<security mode="TransportWithMessageCredential" >
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
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: Configuration binding extension 'system.serviceModel/bindings/clearUsernameBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.
please help
Seems like you are receiving the "An error occurred when verifying security for the message" exception because you have not manually modified the configuration file on the client.
The author states the following in the comments:
As for the desktop application, the client needs to manually configure
clearUsernameBinding as done in the sample console application. The
reason is that the clearUsernameBinding dll is not part of .Net 3.5
and needs to be deployed on the client side.
I get "Endpoint not found" when attempting to access my service via the browser at
http://localhost:10093/Services/Service1.svc
I get "Error: Cannot obtain Metadata from http://localhost:10093/Services/Service1.svc" when attempting to access the same address from the wcftestclient.
If I place a breakpoint in the service implementation it is hit, so I assume the svc file is setup correctly:
<%# ServiceHost Language="C#" Debug="true"
Service="MyApp.Core.Service.Service.MyAppService,MyApp.Core.Service"
Factory="CommonServiceFactory.WebServiceHostFactory,CommonServiceFactory" %>
Here is my config:
<system.serviceModel>
<services>
<service name="MyApp.Core.Service.Service.MyAppService,MyApp.Core.Service"
behaviorConfiguration="MainServiceBehavior">
<endpoint name="newEndpoing"
binding="basicHttpBinding" bindingConfiguration=""
contract="MyApp.Core.Service.IMyAppService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MainServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
So you have a *.svc file to host your service. Can you right-click in Visual Studio on that file and say "Show in Browser" ? Do you get anything there, or does it throw an error right away??
Next: your service endpoint has no address="" attribute, which I believe is mandatory - try adding that (even if you don't specify an address in it).
If you're hosting in IIS, your service address is defined by the virtual directory where your SVC file is present, and the SVC file itself - you might not be able to define a specific port or anything (IIS will handle that).
So try to connect to
http://localhost/Services/Service1.svc
Does that work by any chance??
Update: reading your post again more closely, you're specifying a special factory for the service - WebServiceHostFactory. Is this the default WebServiceHostFactory provided by .NET, or is that something you built yourself??
The point is: the .NET WebServiceHostFactory will use the webHttpBinding for RESTful WCF services - that won't work with an endpoint specifying basicHttpBinding, nor will the REST service have any metadata....
Update #2: try to use just the service's fully qualified class name, but without the assembly specification, in both your SVC file, and the config file.
So change this:
Service="MyApp.Core.Service.Service.MyAppService,MyApp.Core.Service"
to this:
Service="MyApp.Core.Service.Service.MyAppService"
SVC file:
<%# ServiceHost Language="C#" Debug="true"
Service="MyApp.Core.Service.Service.MyAppService" %>
Config file:
<services>
<service name="MyApp.Core.Service.Service.MyAppService"
behaviorConfiguration="MainServiceBehavior">
<endpoint name="newEndpoing"
binding="basicHttpBinding" bindingConfiguration=""
contract="MyApp.Core.Service.IMyAppService" />
</service>
</services>
On your Solution Explorer, open your .svc by using "view markup", make sure you have something like:
... ServiceHost Language="C#" Debug="true"
Service="Yourservice.yourservice" CodeBehind="yourservice.svc.cs" %>
Where Yourservice is your namespace and yourservice is name of your .svc created.
I had the same results (Endpoint not found) when I put this in the browser window
http://c143253-w7a:2221/ws/myService.svc
Then when I put the whole url to the method, it ran fine. Like this
http://c143253-w7a:2221/ws/myService.svc/HelloWorld?theInput=pds
In my .svc file I am using this
Factory="System.ServiceModel.Activation.WebServiceHostFactory"
I think that the Factory doesn't spin up the endpoint until it is needed. That is why we get Endpoint not found in the browser(?).
Here is what the method signature looks like in the interface code.
using System.ServiceModel.Web;
[WebGet(UriTemplate = "HelloWorld?theInput={theInput}")]
[OperationContract]
string HelloWorld(string theInput);
I put nothing in the webconfig. There is some stuff in there, but I think that came in w the VS, Add WCF Service template. It looks like this:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
my web.config for my WCF service is very similar to yours. You definitely have to add the MEX endpoint like Shiraz said. I've added a behavior configuration that lets any message size go through the WCF. Try to use these settings if it can help you (don't forget to change the contract settings):
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="524288000" maxBufferPoolSize="524288000" maxReceivedMessageSize="524288000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="500000000" maxStringContentLength="500000000" maxArrayLength="500000000" maxBytesPerRead="500000000" maxNameTableCharCount="500000000" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="">
<extendedProtectionPolicy policyEnforcement="Never"/>
</transport>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<dataContractSerializer maxItemsInObjectGraph="6553600" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="serviceBehavior" name="RC.Svc.Web.TPF.Service">
<endpoint
address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService"
contract="RC.Svc.Web.TPF.IService" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<client />
Your error message is "Cannot obtain Metadata" and you do not have a MetadataExchange endpoint defined. You do have httpGetEnabled="True", which is also required.
Try defining a MEX endpoint, for details how to see: http://bloggingabout.net/blogs/dennis/archive/2006/11/09/WCF-Part-4-3A00-Make-your-service-visible-through-metadata.aspx
I've set up a WCF web service to be called from my web site. It's working great, but if I request a large amount of data (not sure on the size, but it's easily 3-4 times larger than the "standard" data I'm returning), Cassini (Visual Studio Web Server) just closes the response without sending anything-- no error or anything. Nothing in event log. Just nada.
I'm a newbie to WCF, but I know there must be some configuration option I'm missing here (like a message/response max size/limit) that solves my problem. Here's what my web.config section looks like:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<behaviors>
<endpointBehaviors>
<behavior name="securetmhAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="tmhsecureBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="securetmh">
<endpoint address="" behaviorConfiguration="securetmhAspNetAjaxBehavior" binding="webHttpBinding" contract="securetmh" />
</service>
</services>
</system.serviceModel>
Any help would be appreciated.
For security reasons, WCF limits the data returned by a service call to 64 K by default.
You can obviously change that - there's a gazillion of entries to tweak. See this sample config here:
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="customWebHttp"
maxBufferPoolSize="256000"
maxReceivedMessageSize="256000"
maxBufferSize="256000">
<readerQuotas
maxArrayLength="256000"
maxStringContentLength="256000"/>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="YourService">
<endpoint name="test"
address="....."
binding="webHttpBinding"
bindingConfiguration="customWebHttp"
contract="IYourService" />
</service>
</services>
</system.serviceModel>
You need to define a custom binding configuration based on the webHttpBinding, and you can tweak all those various settings - I set them all to 256K (instead of 64K).
Hope this helps!