This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

.NET service consumption from Java servlet  RSS feed

 
Vijesh Vijayanath
Greenhorn
Posts: 26
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
We would like to consume a .NET web service (.asmx) from Java servlet. While accessing the .NET web service through SoapUI tool, it asks for username, password and domain. Once providing these credentials it is working fine and getting the proper responses.

But we don’t know how to provide these credentials from Java servlet to the .NET web service. Please provide a solution for this.

Thanks in advance.

Thanks,
Vijesh V. Nath
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would generate Java client code like for any other web service. All major SOAP stacks have a tool that does this, e.g. Axis2 comes with wsdl2java. Check the documentation of whichever SOAP stack you intend to use to see what it offers.
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vijesh,
But we don’t know how to provide these credentials from Java servlet to the .NET web service.

This is a basic problem. WSDL you have got should contain operations for authentication and these must be invoked first before doing any application specific web service operation invocation. There are many other ways how your client gets authenticated at the web service end like for example you might have to obtain digital certificate from service provider. You have to check with service provider for the details of their service invocation.
 
Vijesh Vijayanath
Greenhorn
Posts: 26
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naren Chivukula wrote:Hi Vijesh,
But we don’t know how to provide these credentials from Java servlet to the .NET web service.

This is a basic problem. WSDL you have got should contain operations for authentication and these must be invoked first before doing any application specific web service operation invocation.


Thanks a lot for the immediate reply.
But, how can we do this?

i think if this is working fine in SoapUI tool, it sould work fine from our servlet also...right? (as both are java)
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vijesh,
Some applications expose authentication methods within WSDL and validate using application code but some rely on other authentication mechanisms like basic/form/etc. where they use Server to authenticate incoming requests.
i think if this is working fine in SoapUI tool, it sould work fine from our servlet also...right? (as both are java)

While accessing the .NET web service through SoapUI tool, it asks for username, password and domain. Once providing these credentials it is working fine and getting the proper responses.

How did you provide username, password and domain details in SOAP UI?

Also, it might be worth to check this link
 
Vijesh Vijayanath
Greenhorn
Posts: 26
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you provide username, password and domain details in SOAP UI?


While creating the newSoapUI project, we have to enter the project name and webservice link ( https://xyz.com/abc.asmx?wsdl ).
Once we click on OK button, a window will pop up and asks for username, password and domain. If we input everything correct, the stubs will generate.

After that if we try to request any of the methods, we needs to set the same parameters in the "Request properties" section of the request. Then everything will work fine.
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, did you manage to go through the link I provided earlier?
 
Vijesh Vijayanath
Greenhorn
Posts: 26
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naren Chivukula wrote:Okay, did you manage to go through the link I provided earlier?


Yes. We have followed the link that you provided and we implemented the http basic authentication mentioned there. But still we are facing the same problem. http basic authentication allows only to enter username and password. But in our case we have domain also.

We also tried "domain\\username" in place of username, still not working
 
Vijesh Vijayanath
Greenhorn
Posts: 26
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers ,

Problem solved!!!

The web service I was using uses the NTLM authetication (Advanced "Basic HTTP Authentication").

So we added 2 more .jar files in to the lib folder.
1. commons-codec-1.4.jar - http://commons.apache.org/codec/download_codec.cgi
2. commons-httpclient-3.1.jar - http://hc.apache.org/downloads.cgi

After that we extracted axis.jar and made changes to "client-config.wsdd" in the org\apache\axis\client folder as mentioned below.

Modified "transport name="http" pivot="java: org.apache.axis.transport.http.HTTPSender"" to "transport name="http" pivot="java: org.apache.axis.transport.http.CommonsHTTPSender""

Thanks a lot for all for the discussions.


 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for posting back with solution.

This might help someone facing similar problem anytime later.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!