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
Paul Clapham
Ron McLeod
Jeanne Boyarsky
Tim Cooke
Sheriffs:
Liutauras Vilda
paul wheaton
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Carey Brown
Frits Walraven
Bartenders:
Piet Souris
Himai Minh
Forum:
Web Services
Server did not recognize the value of HTTP Header SOAPAction:
Harshit Shrivastava
Greenhorn
Posts: 5
posted 6 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have made a
java
application which calls the C# web service. Here is the code.
package callwebserviceadd; import java.util.Iterator; import javax.xml.soap.*; import javax.xml.transform.*; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Node; public class CallWebServiceAdd { public static void main(String[] args) { // TODO code application logic here String a = "10"; String b = "20"; String op = "Addweb"; String urn = "WebService1"; String dest = "http://localhost:1267/WebService1.asmx"; try { SOAPConnectionFactory soapConnFact = SOAPConnectionFactory.newInstance(); SOAPConnection conn = soapConnFact.createConnection(); MessageFactory msgFact = MessageFactory.newInstance(); SOAPMessage msg = msgFact.createMessage(); SOAPPart soapPart = msg.getSOAPPart(); SOAPEnvelope envelop = soapPart.getEnvelope(); SOAPBody body = envelop.getBody(); SOAPElement bodyelement = body.addChildElement("Addition"); SOAPElement bodyelement1 = bodyelement.addChildElement("a").addTextNode(a); SOAPElement bodyelement2 = bodyelement.addChildElement("b").addTextNode(b); MimeHeaders headers = msg.getMimeHeaders(); headers.addHeader("SOAPAction", dest); msg.writeTo(System.out); msg.saveChanges(); SOAPMessage reply = conn.call(msg, dest); soapPart = reply.getSOAPPart(); envelop = soapPart.getEnvelope(); body = envelop.getBody(); Iterator iter = body.getChildElements(); Node resultOuter = ((Node)iter.next()).getFirstChild(); Node result = resultOuter.getFirstChild(); System.out.println("add(" + a + ","+ b + ") = " + result.getNodeValue()); TransformerFactory transFact = TransformerFactory.newInstance(); Transformer transformer = transFact.newTransformer(); Source sourceContent = reply.getSOAPPart().getContent(); StreamResult res = new StreamResult(System.out); transformer.transform(sourceContent, res); conn.close(); } catch(Exception e) { System.out.println(e.getMessage()); } } }
Result
add(10,20) = soap:Client
Expected Result
add(10,20) = 30
c# webservice code
public class WebService1: System.Web.Services.WebService { [WebMethod] public int AddProg(int a, int b) { return a + b; } }
Returned XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <soap:Fault> <faultcode> soap:Client</faultcode><faultstring> System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://localhost:1267/WebService1.asmx. at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response) 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> BUILD SUCCESSFUL (total time: 1 second)
Why java program is printing unexpected result i.e. `soap:Client` ?
Tim Moores
Saloon Keeper
Posts: 7320
170
posted 6 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I'm not familiar with C# WS, but I would expect the SOAPAction header to indicate which operation should be carried out, like "AddProg".
You might want to ask this in a .Net forum, since it's a server-side issue.
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
I am getting error in my web service code server didnot recognize
Output as null
Consume .Net webservice
convert soap RPC call to document/literal
faultcodeClient.NoSOAPAction
More...