Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Web Services
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Web Services
I am getting error in my web service code server didnot recognize
monis raza
Ranch Hand
Posts: 38
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am using
soap
1.1 in which i have to send a soapaction in http header. searched everywhere but could not find solution.
/** * */ package testsoap; import javax.xml.namespace.QName; import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPBody; import javax.xml.soap.SOAPBodyElement; import javax.xml.soap.SOAPConnection; import javax.xml.soap.SOAPConnectionFactory; import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPEnvelope; import javax.xml.soap.SOAPHeader; import javax.xml.soap.SOAPMessage; import javax.xml.soap.SOAPPart; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; /** * @author admin * */ public class SoapClient { private static SOAPMessage createSOAPRequest() throws Exception { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); soapEnvelope.setPrefix("soap"); soapEnvelope.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance"); soapEnvelope.addNamespaceDeclaration("xsd", "http://www.w3.org/2001/XMLSchema"); soapEnvelope.addNamespaceDeclaration("soap", "http://schemas.xmlsoap.org/soap/envelope/"); SOAPHeader soapHeader = soapMessage.getSOAPHeader(); soapHeader.setPrefix("soap"); soapHeader.addNamespaceDeclaration("SOAPAction","http://wsdl.echelon.com/Panoramix/Login"); SOAPBody soapBody = soapEnvelope.getBody(); soapBody.setPrefix("soap"); SOAPBodyElement soapbodyElement = soapBody.addBodyElement(new QName( "http://wsdl.echelon.com/Panoramix/", "Login")); SOAPElement soapElement = soapbodyElement.addChildElement(new QName( " ", "sUserLogin")); soapElement.addTextNode(" "); SOAPElement soapElementOne = soapElement.addChildElement(new QName( " ", "sPassword")); soapElementOne.addTextNode(" "); SOAPElement soapElementTwo = soapElementOne.addChildElement(new QName( " ", "sAuthenticationTypeID")); soapElementTwo.addTextNode("string"); soapMessage.writeTo(System.out); System.out.println(); return soapMessage; } private static void printSOAPResponse(SOAPMessage soapResponse) throws Exception { TransformerFactory transformerFactory = TransformerFactory .newInstance(); Transformer transformer = transformerFactory.newTransformer(); Source sourceContent = soapResponse.getSOAPPart().getContent(); System.out.println("\nResponse SOAP Message = "); StreamResult result = new StreamResult(System.out); transformer.transform(sourceContent, result); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try { // Create SOAP Connection SOAPMessage soapResponse = null; SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory .newInstance(); SOAPConnection soapConnection = soapConnectionFactory .createConnection(); // Send SOAP Message to SOAP Server String url = "http://182.18.160.120/CoreServices/DeviceManager.asmx"; soapResponse = soapConnection.call(createSOAPRequest(), url); // Process the SOAP Response printSOAPResponse(soapResponse); soapConnection.close(); } catch (Exception e) { System.err .println("Error occurred while sending SOAP Request to Server"); e.printStackTrace(); } } }
error which i am getting is
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Header xmlns:SOAPAction="http://wsdl.echelon.com/Panoramix/Login"/><soap:Body><Login xmlns="http://wsdl.echelon.com/Panoramix/"><sUserLogin xmlns=" "> <sPassword> <sAuthenticationTypeID>C8D75848B3A9441f8B0165EF75554C0D</sAuthenticationTypeID></sPassword></sUserLogin></Login></soap:Body></soap:Envelope> Response SOAP Message = <?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>Server did not recognize the value of HTTP Header SOAPAction: .</faultstring><detail/></soap:Fault></soap:Body></soap:Envelope>
Kesava Krishna
Ranch Hand
Posts: 44
posted 10 years ago
1
Number of slices to send:
Optional 'thank-you' note:
Send
Please use SOAPHeader saopHeader = <SOAPEnvelope object>.addHeader() and let me know the results. Also make sure while setting the SOAPAction the service should be available in that url
Thanks,
Kesava.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
error while connecting to webservices
unable to connect to .Net web service using axis with java
Getting Bad Response from Web service
SOAP Exception : did not recognize the value of HTTP Header SOAPAction:
SOAP Fault for SOAP Action property
More...