• 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

.NET service consumption from Java servlet

 
Greenhorn
Posts: 26
Android Java ME Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 577
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ME Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ME Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, did you manage to go through the link I provided earlier?
 
Vijesh Vijayanath
Greenhorn
Posts: 26
Android Java ME Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ME Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for posting back with solution.

This might help someone facing similar problem anytime later.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic