I've created a WCF Service to upload images. It works fine with images < 50KB or so but I get "The remote server returned an error: (400) Bad Request." with larger images.
I've been looking for ages and tried lots of different things, including setting the maxRequestLength and several other settings.
On the client-side of things the web.config is picking it up as a basicHttpBinding and I'm after a wsHttpBinding (for the more up-to-date feature-set). If I manually change the the binding type to wsHttpBinding and change the corresponding options, I get a Unsupported Media Type error.
Lookingin the WCF Test Client it shows the service as a basicHttpBinding too.
So my question is two-fold really.
What do I need to do to allow my service to handle files > 50KB?
What do I need to change for my service to be recognised as wsHttp instead of basicHttp?
Apologies if there is a question answering these - I have scoured stackoverflow and tried a few suggestions but it is possible I've missed it!
EDIT: As is always the way, I've managed to solve the wsHttpBinding issue now by fiddling around with the service web.config and manually changing the endpoint to wsHttpBinding. Still getting the large upload filesize issue though.
you will need to update your bindings in you web.config
e.g. this is how i did in my wcf restful service. i believe it will be very similar in your case as well
<bindings>
<webHttpBinding>
<!-- buffer: 64KB; max size: 64MB -->
<binding name="StreamedBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Streamed"
maxBufferPoolSize="67108864" maxBufferSize="65536" maxReceivedMessageSize="67108864">
</binding>
</webHttpBinding>
</bindings>
<service name="WCFRestFul.ApiRestful">
<endpoint address="" binding="webHttpBinding"
bindingConfiguration="StreamedBinding" bindingName="StreamedBinding"
contract="WCFRestFul.IApiRestful" behaviorConfiguration="web" />
</service>
Related
There is similar question is available here
GZIP compress the request to a remote web service via WCF
When I have implemented solution provided by expert
i.e. WCF client endpoint compression
here is my web.config file code
<bindings>
<customBinding>
<binding name="NAME" >
<binaryMessageEncoding compressionFormat="GZip"/>
<httpsTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="MYENDPOINTURL"
binding="customBinding" bindingConfiguration="NAME"
contract="ICONTRACT" name="BulkRequestTransmitterPort" />
</client>
below is error I am getting
Error: The content type text/xml;charset=utf-8 of the response message does not match the content type of the binding (application/soap+msbin1+gzip). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 807 bytes of the response were: '
soapenv:Client
The request message must be sent using HTTP compression (RFC 1952 - GZIP).
TPE1112
'
Can someone please tell me where I am doing wrong?``
Thanks
Here is the complete error message:
Message security verification failed.
Cannot read KeyIdentifierClause from element 'KeyIdentifier' with namespace
'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'.
Custom KeyIdentifierClauses require custom SecurityTokenSerializers, please refer to the SDK for examples
Here is the story: We are trying to implement a WCF client which talks to a non-WCF web service and most likely the web service has been implemented on J2EE platform. The message sent out from WCF client has to be signed. Fortunately, we were able to find a post at stackoverflow and were able to follow the guidelines / tips in that post. Below is the custom binding:
<customBinding>
<binding name="AccountServiceSoap11Binding1" sendTimeout="00:05:00">
<textMessageEncoding messageVersion="Soap11" />
<security authenticationMode="MutualCertificate" enableUnsecuredResponse="true" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
</security>
<httpsTransport />
</binding>
</customBinding>
We were able to send the request and server responds nicely (we could see the response using fiddler2). Everything works except for the above exception occurred. We did search and found out couple suggestions or clues listed below:
One: sceanairo#12: Incorrect version of security header
blogs.msdn.com/b/distributedservices/archive/2011/03/07/wcf-security-interop-scenarios.aspx
Two: ask vendor to make some changes
social.msdn.microsoft.com/Forums/vstudio/en-US/0732bb4d-7dbb-4b43-8821-3f0caba600eb/cannot-read-keyidentifierclause-from-element-x509issuerserial-with-namespace?forum=wcf
Please advise what we could do to avoid the exception.
Many thanks,
Peter
I've been trying to add TLS to a WCF service, I've created.
Everything is OK until I try to access the service through https instead of http.
When adding the wcf service to the wcf test client, I get this:
Error: Cannot obtain Metadata from [THELINK] If this is a Windows (R)
Communication Foundation service to which you have access, please
check that you have enabled metadata publishing at the specified
address. For help enabling metadata publishing, please refer to the
MSDN documentation at [an MS link] Exchange Error URI: [THELINK]
Metadata contains a reference that cannot be resolved: '[THELINK]'.
There was no endpoint listening at [THELINK] that could accept the
message. This is often caused by an incorrect address or SOAP action.
See InnerException, if present, for more details. The remote server
returned an error: (403) Forbidden.HTTP GET Error URI: [THELINK]
There was an error downloading '[THELINK]'. The request failed with
HTTP status 403: Forbidden.
Sorry about the link replacing, but I'm new and I don't have the reputation, it seems :)
Regards,
Morten
do you have a
<behaviors>
<serviceBehaviors>
<behavior name="YourSerivceBehaviourName">
<serviceMetadata httpsGetEnabled="true" /> <-- this bit ?
...
...
being referenced by your
<service name="...." behaviorConfiguration="YourSerivceBehaviourName">
or a
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
in your web.config?
the Test client will also moan if the certificate isn't a real one I have found.. ie a self certed one for testing.
but the 403 seems to suggest that whatever credentials you are supplying are incorrect, what is the clientCredentialType set to in the SSL binding?
and what happens if you hit the link in a browser with customerrors off..
this might give you some more useful information
Learning WCF (I know, late to the party)
I am working through Juval Lowy's Programming WCF book. I see that I can configure multiple endpoints (including URI's) for my service.
However, when I host these in IIS, only the location of the .svc file seems to matter. Is the multiple endpoints/addresses thing only applicable if you are self-hosting? Am I missing something about hosting services in IIS?
"only the location of the .svc ", you're heading to this because baseaddress are provided by IIS in case of web-hosting (IIS hosting) unless you're using CustomServiceHostFactory. Then whatever value you provide in address, are appended to baseaddress (.svc/..)
You needs to give several host name in IIS for the the same WCF and set several endpoints in the client section of web.config as:
<client>
<endpoint address="hostname1/myservice.svc" ... />
<endpoint address="hostname2/myservice.svc" ... />
<endpoint address="hostname3/myservice.svc" ... />
</client>
Then you can consume them as:
hostname1/myservice.svc
hostname2/myservice.svc
hostname3/myservice.svc
I am building an single application that uses WCF to call out to multiple external endpoints. All of the remote endpoints are identical except for the URI. I would like to treat them as a pool: add and remove endpoints through configuration and have the application understand what to do.
My original plan was to define one endoint in the app.config, then iterate over my list of endpoints and update client.Endpoint.Address on the fly to point to the right place. Unfortunately, that property is read-only, rendering that plan unworkable.
I'm a little bit stumped here. Any suggestions on how I might accomplish this?
How to: Create a Service Endpoint in Code shows you how to manage service endpoints in code rather than configuration.
Have you tried a separate name that is passed in to the client constructor?
<endpoint address="http://localhost:18000/MyService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
contract="MyServiceReference.IMyService" name="BasicHttpBinding_IMyService" />
<endpoint address="http://localhost:18001/MyService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
contract="MyServiceReference.IMyService" name="MyService_Secondary" />
<endpoint address="http://localhost:18002/MyService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
contract="MyServiceReference.IMyService" name="MyService_Tertiary" />
Store the end point addresses in a DB table and use Jason's suggestion for creating end points in code. When a new endpoint shows up you just add another row to the table and force the service to re-query the endpoint table.
How to: Create a Service Endpoint in Code
http://msdn.microsoft.com/en-us/library/ms731080.aspx