Error consuming webservice, content type “application/xop+xml” does not match expected type “text/xml”

For anyone suffering from the same problem; I’ve found a solution for consuming the web service as a Service Reference (WCF). The BasicHttpBinding.MessageEncoding property needs setting to “Mtom”. Here’s a snippet of the required config setting: <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding messageEncoding=”Mtom”> </binding> </basicHttpBinding> </bindings> </system.serviceModel> </configuration> Edit: If you are having the same issue … Read more

HttpDelete with body

Have you tried overriding HttpEntityEnclosingRequestBase as follows: import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; import java.net.URI; import org.apache.http.annotation.NotThreadSafe; @NotThreadSafe class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase { public static final String METHOD_NAME = “DELETE”; public String getMethod() { return METHOD_NAME; } public HttpDeleteWithBody(final String uri) { super(); setURI(URI.create(uri)); } public HttpDeleteWithBody(final URI uri) { super(); setURI(uri); } public HttpDeleteWithBody() { super(); } } … Read more

javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake during web service communicaiton

Java 7 defaults to TLS 1.0, which can cause this error when that protocol is not accepted. I ran into this problem with a Tomcat application and a server that would not accept TLS 1.0 connections any longer. I added -Dhttps.protocols=TLSv1.1,TLSv1.2 to the Java options and that fixed it. (Tomcat was running Java 7.)

Client to send SOAP request and receive response

I normally use another way to do the same using System.Xml; using System.Net; using System.IO; public static void CallWebService() { var _url = “http://xxxxxxxxx/Service1.asmx”; var _action = “http://xxxxxxxx/Service1.asmx?op=HelloWorld”; XmlDocument soapEnvelopeXml = CreateSoapEnvelope(); HttpWebRequest webRequest = CreateWebRequest(_url, _action); InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest); // begin async call to web request. IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null); // suspend this thread … Read more