I'm getting a bad response frm a web service that I'm trying to consume.
This is the request SOAP msg that I need to generate:
POST /CurrencyConvertor.asmx HTTP/1.1 Host: www.webservicex.net Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://www.webserviceX.NET/ConversionRate" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ConversionRate xmlns="http://www.webserviceX.NET/"> <FromCurrency>USD</FromCurrency> <ToCurrency>QRR</ToCurrency> </ConversionRate> </soap:Body> </soap:Envelope>
And this is my code :
// Create connection and message factory SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnectionFactory.createConnection(); MessageFactory messageFactory = MessageFactory.newInstance(); // Create a message SOAPMessage message = messageFactory.createMessage(); // Get the SOAP header and body from the message // and remove the header SOAPHeader header = message.getSOAPHeader(); SOAPBody body = message.getSOAPBody(); header.detachNode(); // Create a SOAP factory // Create a UDDI v2 find_business body element SOAPFactory soapFactory = SOAPFactory.newInstance(); SOAPBodyElement findBusiness = body.addBodyElement(soapFactory.createName( "ConversionRate", "", "http://www.webserviceX.NET/")); SOAPElement from = findBusiness.addChildElement( soapFactory.createName("FromCurrency") ); from.addTextNode("USD"); SOAPElement to = findBusiness.addChildElement( soapFactory.createName("ToCurrency") ); to.addTextNode("BDT"); message.saveChanges();
I cudnt find any error in my code but I get this response frm the service :
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <soap:Fault> <faultcode>soap:Client</faultcode> <faultstring>System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: . at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)</faultstring> <detail /> </soap:Fault> </soap:Body> </soap:Envelope>
Any ideas?? Any sorta help wud be gr8ly appreciated.