java - Getting Error in SOAP POST request using Apache CXF but curl works -


i'm having strange problem. i'm trying soap post request on https. when i'm sending request code, i'm getting http 500 error. cxf log if copy same soap message(header , body) got error , post using simple curl request it's working fine. below how i'm creating service class , other initialization

url wsdlurl = soapwebservicetransport.class.getclassloader().         getresource("my.wsdl"); onlineport service= new onlineportservice(wsdlurl).getonlineportport(); client proxy = clientproxy.getclient(service);  // provides ws-security wss4joutinterceptor wss4jout = new wss4joutinterceptor(); wss4jout.setproperty("action", "usernametoken"); wss4jout.setproperty("user", username); wss4jout.setproperty("passwordtype", "passwordtext"); wss4jout.setproperty("password", password); wss4jout.setproperty(wshandlerconstants.add_ut_elements,         wsconstants.nonce_ln + " " + wsconstants.created_ln); wss4jout.setproperty(wshandlerconstants.pw_callback_class, serverpasswordcallback.class.getname());  proxy.getendpoint().getoutinterceptors().add(wss4jout); setconduitproperties((httpconduit) proxy.getconduit(),url); 

in set conduit method i'm ignoring ssl check (for development env only) , setting header.

tlsclientparameters tcp = new tlsclientparameters(); tcp.setdisablecncheck(true); // creating trust manager trustmanager[] trustallcerts = new trustmanager[] {     new x509trustmanager() {         public java.security.cert.x509certificate[] getacceptedissuers() {             return null;         }          public void checkclienttrusted(                 java.security.cert.x509certificate[] certs, string authtype) {         }          public void checkservertrusted(                 java.security.cert.x509certificate[] certs, string authtype) {         } } };  tcp.settrustmanagers(trustallcerts); conduit.settlsclientparameters(tcp);  httpclientpolicy httpclientpolicy = new httpclientpolicy(); httpclientpolicy.setallowchunking(false); httpclientpolicy.setaccept("*/*"); httpclientpolicy.setcontenttype("text/xml;charset=utf-8"); httpclientpolicy.sethost(url.split("/")[2]); conduit.setclient(httpclientpolicy); 

any highly appreciable.

response-code: 500 encoding: iso-8859-1 content-type: text/html;charset=iso-8859-1 headers: {connection=[close], content-type=[text/html;charset=iso-8859-1],           date=[mon, 15 jun 2015 06:42:09 gmt], server=[apache-coyote/1.1],           set-cookie=[jsessionid=ff0e4f5dca42f700ffac46bbd039fc20; path=/; secure],           transfer-encoding=[chunked]} payload:   <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">  > <html> <head> <meta http-equiv="content-type" content="text/html; > charset=iso-8859-1"/> <title>error page</title> </head> <body>invalid > request </body> </html>   @ org.apache.cxf.interceptor.staxininterceptor.handlemessage(staxininterceptor.java:79)     @ org.apache.cxf.phase.phaseinterceptorchain.dointercept(phaseinterceptorchain.java:263)     @ org.apache.cxf.endpoint.clientimpl.onmessage(clientimpl.java:797)     @ org.apache.cxf.transport.http.httpconduit$wrappedoutputstream.handleresponseinternal(httpconduit.java:1618)     @ org.apache.cxf.transport.http.httpconduit$wrappedoutputstream.handleresponse(httpconduit.java:1491)     @ org.apache.cxf.transport.http.httpconduit$wrappedoutputstream.close(httpconduit.java:1399)     @ org.apache.cxf.io.cacheandwriteoutputstream.postclose(cacheandwriteoutputstream.java:47)     @ org.apache.cxf.io.cachedoutputstream.close(cachedoutputstream.java:188)     @ org.apache.cxf.transport.abstractconduit.close(abstractconduit.java:56)     @ org.apache.cxf.transport.http.httpconduit.close(httpconduit.java:646)     @ org.apache.cxf.interceptor.messagesenderinterceptor$messagesenderendinginterceptor.handlemessage(messagesenderinterceptor.java:62)     @ org.apache.cxf.phase.phaseinterceptorchain.dointercept(phaseinterceptorchain.java:263)     @ org.apache.cxf.endpoint.clientimpl.doinvoke(clientimpl.java:533)     @ org.apache.cxf.endpoint.clientimpl.invoke(clientimpl.java:463)     @ org.apache.cxf.endpoint.clientimpl.invoke(clientimpl.java:366)     @ org.apache.cxf.endpoint.clientimpl.invoke(clientimpl.java:319)     @ org.apache.cxf.frontend.clientproxy.invokesync(clientproxy.java:88)     @ org.apache.cxf.jaxws.jaxwsclientproxy.invoke(jaxwsclientproxy.java:134)  caused by: org.apache.cxf.interceptor.fault: response of unexpected text/html contenttype.  incoming portion of html stream:  

curl request

curl -k --header "content-type: text/xml;charset=utf-8" --header "soapaction:" --data @soaprequest.xml https://url

curl log in verbose (ofcourse have changed url port names0

error response server

    <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> <title>error page</title> </head> <body>invalid request </body> </html>  

if can't access log on server can try check if code request , curl request different.

to can sniff http request sniffer tcpmon.

tcpmon operates proxy between client , server. intercepts requests , print details of each request , response.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -