WCF SOAP Service Gzip encoding with Custom Binding - wcf

Need help in sending a request which is for WCF service. The service has Custom Binding ( The request is Binary encoded).
Initially i was getting the HTTP/1.1 415 Cannot process the message because the content type 'application/soap+xml;charset=UTF-8;action="Phase"' was not the expected type 'application/soap+msbin1+gzip'.
So I manually added a header Content-Type = 'application/soap+msbin1+gzip'. Now the previous error was gone. but now I am getting the following error: "The remote server returned an error: (400) Bad Request"
I am using HttpWebRequest.
Below images for the reference
Code image
Error line Where i got 400

Related

Why does get my response error message got truncated

I'm new to the WorldPay integration development.
I'm having difficulty when I am sending an authorization request from one of our applications and I got this response from the api .
Client error: POST https://try.access.worldpay.com/payments/authorizations resulted in a 400 Bad Request response: {"errorName":"bodyDoesNotMatchSchema","message":"The json body provided does not match the expected schema","validationE (truncated...)
My problem is I was unable to see the complete error message because the response has been truncated. Is there a way to prevent that issue?

Unable to programmatically set Content-Type in BizTalk Wcf-Custom response port

I am attempting to receive JSON messages into BizTalk using the bLogical REST Start Kit for BizTalk (http://biztalkrest.codeplex.com/).
I am able to successfully receive a message, transform it, and return a response from my Orchestration, but when I transform the response back out through the BizTalkRESTResponseHandler, the HTTP Content-Type is being forced back to 'application/xml', even though I'm explicitly setting it to 'application/json'. The Content-Type is confirmed by tracing the Request and Response in Fiddler, as well as SoapUI.
The Accept: value on the Request is 'application/json'
Any ideas how I can trace further into the Wcf-Custom adapter stack to see where the Content-Type is being reset?
You can solve this by adding a HttpResponseMessageProperty before returning the message in the IDispatchMessageInspector. You can either do this directly in the BizTalkRESTResponseHandler IDispatchMessageInspector or in a separate one.
To do it in the BizTalkRESTResponseHandler get the source and add the following 3 lines of code in the BeforeSendReply method just above the "reply = newReply" in the end.
HttpResponseMessageProperty prop = new HttpResponseMessageProperty();
newReply.Properties.Add(HttpResponseMessageProperty.Name, prop);
prop.Headers.Add("Content-Type", "application/json;charset=utf-8");
Now instead of getting:
You will get this:

HTTP Status Code: 401 in GCMDemo

Reference:http://developer.android.com/google/gcm/demo.html
Server 401 when trying to send a message to my android device.
HTTP Status 500 - HTTP Status Code: 401
type Exception report
message HTTP Status Code: 401
description The server encountered an internal error (HTTP Status Code: 401) that prevented it from fulfilling this request.
exception
com.google.android.gcm.server.InvalidRequestException: HTTP Status Code: 401
com.google.android.gcm.server.Sender.sendNoRetry(Sender.java:177)
com.google.android.gcm.server.Sender.send(Sender.java:121)
com.google.android.gcm.demo.server.SendAllMessagesServlet.doPost(SendAllMessagesServ let.java:83)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.29 logs.
Could anybody tell me how to solve?Thank you!
You should take a look at the GCM docs where it explains the GCM response: http://developer.android.com/google/gcm/gcm.html#response and troubleshooting the 401 error code: http://developer.android.com/google/gcm/gcm.html#auth_error
Description from the docs:
Authentication Error
The sender account that you're trying to use to
send a message couldn't be authenticated. Possible causes are:
Authorization header missing or with invalid syntax.
Invalid project number sent as key.
Key valid but with GCM service disabled.
Request originated from a server not whitelisted in the Server Key IPs.
So I would check to make sure that you are setting you authorization header properly and that you Google Project number is properly setup with GCM and accepting your servers IP.

Consuming sharepoint 2010 claim-based WCF

I am trying to consume WCF based Sharepoint 2010 claim-based. I am getting the following error message: Thank you for any advice.
System.ServiceModel.CommunicationException
"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 b..."
Whenever you get HTML from a web service, it means you're getting an error message. Look at the network traffic using Fiddler or something to see what the service is trying to tell you.

Should my WCF webservice return a 500 or 200 http code (soap fault / functional return message)

after reading the SOAP 1.1 specs, it states that a SOAP Fault should return a http 500 errorcode when communication goes over a http binding, so when a SoapException is thrown, WCF returns a http 500 error code.
Now, I'm looking for some best practices to when return a functional soap error message and when to return a SOAP Fault.
What would you guys return when a functional error occurred while processing the message because of the input message contains some functional errors, a 500 SOAP Fault or a 200 Soap response containing some error message ?
http://www.ws-i.org/Profiles/BasicProfile-1.1-2006-04-10.html#HTTP_Server_Error_Status_Codes:
3.4.7 HTTP Server Error Status Codes
HTTP uses the 5xx series of status codes to indicate failure due to a server error.
R1126: An INSTANCE MUST return a "500 Internal Server Error" HTTP status code if
the response envelope is a Fault.
UPDATE:
What would you guys return when a
functional error occurred while
processing the message because of the
input message contains some functional
errors, a 500 SOAP Fault or a 200 Soap
response containing some error message
?
If the input message is invalid and prevents your service from doing its intended job, then yes - this clearly constitutes an exception, so I would return a SOAP fault in this case (something like FaultException<InvalidInputParameters>).
And I would let WCF handle all the necessary gory details of whether or not and when to return what http error code, if necessary. WCF already does all of that for you - you just throw a SOAP fault in your service code and that's all there is for you.