File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Call .NET Web Service From JAVA Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Call .NET Web Service From JAVA Client " Watch "Call .NET Web Service From JAVA Client " New topic
Author

Call .NET Web Service From JAVA Client

vijay saraf
Ranch Hand

Joined: Jan 08, 2005
Posts: 141
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.

Actually I am Following This Link
Demo Code

Thanks & Regards,
Vijay Saraf.
[ August 10, 2006: Message edited by: vijay saraf ]

Thanks
Vijay Saraf.
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
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.


Spritle Software Blogs
vijay saraf
Ranch Hand

Joined: Jan 08, 2005
Posts: 141
Hello Sir,

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.

1) KMSService.java
2) KMSServiceLocator.java
3) KMSServiceSoap12Stub.java
4) KMSServiceSoapProxy.java
5) KMSServiceSoapStub.java

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.
 
 
subject: Call .NET Web Service From JAVA Client
 
Similar Threads
Not Authorized as response connecting Webservice in a trusted Domain
Prob. logging in calling a Webservice on Dot-net server
SOAPException: Error opening socket
SOAP Header
SOAP Fault for SOAP Action property