I've built and api in nodejs with the library "soap" that consumes a wsdl project.
Im trying to do a post and in the response body im getting this error: The server cannot service the request because the media type is unsupported ; also in the response body I have this message: Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8. I did some research and figure it out that is a problem of soap version between server and client.
I try this things:
- when creating soap client added forceSoap12Headers:false and viceverse
- rewrite soap library with accept content and content-type to: text/xml; charset=utf-8, also change all schemes that belongs to soap v1.1
- try do add httpHeader in request 'Accept' 'text/xml'
this is part of my code:
MethodTest: async function(wsdl){
try{
var client = soap.createClient(wsdl,{forceSoap12Headers:false},async (err,result)=>{
if(err){
}else{
var descripcion = await this.ServiceDescription(wsdl);
if(!descripcion.error){
var body = { _xml: "<i0:GetAccountBalance>"+
"<i0:dc>"+
"<i0:RequestId>000</i0:RequestId>"+
"<i0:SystemId>WEB</i0:SystemId>"+
"<i0:SourceId>AR</i0:SourceId>"+
"<i0:AccountNumber>42526372</i0:AccountNumber>"+
"</i0:dc>"+
"<i0:dcSecurity>"+
"<i0:WebUser>NDsVwQwRbwbuY / DcX2PRGw ==</i0:WebUser>"+
"<i0:WebPassword>/d8zOcR9K9xqpl8CdhUJrw==</i0:WebPassword>"+
"</i0:dcSecurity>"+
"</i0:GetAccountBalance>"}
try{
var response = await (result[descripcion.metodos[8]+"Async"])(body)
}catch (e){
console.log(e.response)
}
}
}
})
content-type: application/soap+xml
as your request content type. – Nicolas