Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

JAVA/SOAP : Bad response from Web Service


  • Please log in to reply

#1
Dsypher

Dsypher

    Member

  • Member
  • PipPip
  • 97 posts
Hi,

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. :tazz:
  • 0

Advertisements







Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP