Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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