ERROR: in JAVA STAND ALONE: SEVERE: SAAJ0537: Invalid Content-Type. Could be an error message instead of a SOAP message -
below java stand alone class soap client. using keystore also. getting
severe: saaj0537: invalid content-type. error message instead of soap message
exception, tried hard, not able figure out. have attached los below,
code:
public class soapclient { public static void main(string args[]) throws exception { string keystore = "xxxx/keystore_s1_ariba_uat.jks"; system.getproperties().setproperty("javax.net.ssl.keystore",keystore); system.getproperties().setproperty("javax.net.ssl.keystorepassword","xxxx"); system.getproperties().setproperty("javax.net.ssl.truststore", keystore); system.getproperties().setproperty("http.proxyhost", "web-proxy.xxxx.xxxx.net"); system.getproperties().setproperty("https.proxyhost", "web-proxy.xxxx.xxxx.net"); system.getproperties().setproperty("http.proxyport", "8080"); system.getproperties().setproperty("https.proxyport", "8080"); // create soap connection soapconnectionfactory soapconnectionfactory = soapconnectionfactory.newinstance(); soapconnection soapconnection = soapconnectionfactory.createconnection(); // send soap message soap server string url = "https://s1.ariba.com/sourcing/soap/hpegp-t/contractheaderexport?wsdl&validate=false"; soapmessage soapmessage = createsoaprequest(); soapmessage soapresponse = soapconnection.call(soapmessage, url); // print soap response system.out.print("response soap message:"); soapresponse.writeto(system.out); soapconnection.close(); } private static soapmessage createsoaprequest() throws exception { messagefactory messagefactory = messagefactory.newinstance(); //messagefactory messagefactory = messagefactory.newinstance(soapconstants.soap_1_1_protocol); soapmessage soapmessage = messagefactory.createmessage(); soappart soappart = soapmessage.getsoappart(); string serveruri = "urn:ariba:sourcing:vrealm_995"; // soap envelope soapenvelope envelope = soappart.getenvelope(); envelope.setprefix("soapenv"); envelope.addnamespacedeclaration("urn", serveruri); // soap header soapheader soapheader = envelope.getheader(); soapheader.setprefix("soapenv"); soapelement soapheaderelem = soapheader.addchildelement("headers", "urn"); soapelement soapheaderelemvarient = soapheaderelem.addchildelement("variant", "urn"); soapheaderelemvarient.addtextnode("?"); soapelement soapheaderelempartition = soapheaderelem.addchildelement("partition", "urn"); soapheaderelempartition.addtextnode("?"); // soap body soapbody soapbody = envelope.getbody(); soapbody.setprefix("soapenv"); soapelement soapbodyelem = soapbody.addchildelement("contractheaderexportrequest", "urn"); name variantname = envelope.createname("variant"); name partitionname = envelope.createname("partition"); soapbodyelem.addattribute(variantname, "?"); soapbodyelem.addattribute(partitionname, "?"); soapelement soapbodyelemwscontractheader = soapbodyelem.addchildelement("wscontractheaderexportinputbean_item", "urn"); soapelement soapbodyelemitem = soapbodyelemwscontractheader.addchildelement("item", "urn"); soapelement soapbodyelemclassname = soapbodyelemitem.addchildelement("classname", "urn"); soapbodyelemclassname.addtextnode("ariba.collaborate.contracts.contractworkspace"); soapelement soapbodyelemfromdate = soapbodyelemitem.addchildelement("fromdate", "urn"); soapbodyelemfromdate.addtextnode("2015-01-01t12:00:00z"); soapelement soapbodyelemtodate = soapbodyelemitem.addchildelement("todate", "urn"); soapbodyelemtodate.addtextnode("2016-04-29t12:00:00z"); //mime header mimeheaders headers = soapmessage.getmimeheaders(); //headers.addheader("soapaction", serveruri + "contractheaderexportrequest"); headers.addheader("soapaction", serveruri + "contractheaderexportrequest"); headers.setheader("content-type", "text/xml; charset=utf-8"); //headers.setheader("content-type", "text/html; charset=utf-8"); soapmessage.savechanges(); system.out.print("request soap message:"); soapmessage.writeto(system.out); return soapmessage; } }
logs:
may 9, 2016 12:14:19 pm com.sun.xml.internal.messaging.saaj.soap.messageimpl identifycontenttype severe: saaj0537: invalid content-type. error message instead of soap message exception in thread "main" com.sun.xml.internal.messaging.saaj.soapexceptionimpl: com.sun.xml.internal.messaging.saaj.soapexceptionimpl: invalid content-type:text/html. error message instead of soap response? @ com.sun.xml.internal.messaging.saaj.client.p2p.httpsoapconnection.call(httpsoapconnection.java:148) @ com.rnd.ws.soap.soapclient.main(soapclient.java:45) caused by: com.sun.xml.internal.messaging.saaj.soapexceptionimpl: invalid content-type:text/html. error message instead of soap response? @ com.sun.xml.internal.messaging.saaj.soap.messageimpl.identifycontenttype(messageimpl.java:602) @ com.sun.xml.internal.messaging.saaj.soap.messagefactoryimpl.createmessage(messagefactoryimpl.java:86) @ com.sun.xml.internal.messaging.saaj.client.p2p.httpsoapconnection.post(httpsoapconnection.java:328) @ com.sun.xml.internal.messaging.saaj.client.p2p.httpsoapconnection.call(httpsoapconnection.java:144) ... 1 more
cause:
com.sun.xml.internal.messaging.saaj.soapexceptionimpl: invalid content-type:text/html. error message instead of soap response? @ com.sun.xml.internal.messaging.saaj.soap.messageimpl.identifycontenttype(messageimpl.java:602) @ com.sun.xml.internal.messaging.saaj.soap.messagefactoryimpl.createmessage(messagefactoryimpl.java:86) @ com.sun.xml.internal.messaging.saaj.client.p2p.httpsoapconnection.post(httpsoapconnection.java:328) @ com.sun.xml.internal.messaging.saaj.client.p2p.httpsoapconnection.call(httpsoapconnection.java:144) @ com.rnd.ws.soap.soapclient.main(soapclient.java:45)
can please me in this?
Comments
Post a Comment