Hello All, I have to make a web service client.I am doing this by appache-soap. I have make One Proxy as follows.
inSide somemethod (this method i am calling in my client program) { org.apache.soap.messaging.Message _message = new org.apache.soap.messaging.Message();
//My Own Body MessageBody mBody = new MessageBody ();
// Replace the default body with my body this._envelop.setBody (mBody); _message.send ("http://myDomain/SomeService/SomeService.asmx","http://myDomain/SomeService/SomeService.asmx/getEncryption", this._envelop); try { this.soapMessage_ = this._message.receive(); XMLReader reader = (XMLReader)Class.forName("org.apache.xerces.parsers.SAXParser").newInstance(); SAXHandler handler = new SAXHandler(); // .......Some Parsing Code } catch (Exception exception) { exception.printStackTrace (); } } Here i have made my own body (obviously by extending Body )and setted in envelop. Send the message and try to parse the response given by service. But i am getting the Exception as follows :
System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction .
i am little bit confused with send method of Message class. what exactly actionURI (arg no. 2) is. API Specifies as Follows public void send(java.net.URL url,java.lang.String actionURI,Envelope env) throws SOAPException Send an envelope to the given URL via the SOAPTransport that has been configured for this instance (or SOAPHTTPConnection by default). The envelope is sent exactly as-is.
Parameters: url - the url to send to ( ?? ) actionURI - the value of the SOAPAction header ( ?? ) env - envelope to send
If any one have some hint ,example code or any thread link please tell me.
With the given information i can only guess that the SOAP request sent from apachesoap is complaning to .net. If possible try to use some soap monitor to see what requests is being sent and is that what you want to send.
Alternatively, it is better if you switch to Apache Axis as Apache Soap is outdated now.
Actually i was trying with both,i am using eclipse 3.1, which generate default files with axis web service run time as bellow. asuming KMSService.asmx as web service.
but i am confused, how to use those proxy and stub generated, I have made Client as follows
public class TestClient { public static void main(String [] args) { try { String endpoint = "http://MYDOMAIN/KMSService/KMSService.asmx"; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress( new java.net.URL(endpoint) ); call.setOperationName(new QName ("http://tempuri.org/", "getUserDetails"));
// I am confused with this line How can i pass my XML file in this. String ret = (String) call.invoke( new Object[] { "HIRTYUASPWEBCUT10QWEYVBOIDNJH" } );
System.out.println("Result Is "+ ret ); } catch (Exception e) { System.err.println(e.toString()); } } } i request you if you have any idea please reply me.