tag:blogger.com,1999:blog-65402795233846130302023-06-20T06:20:17.859-07:00Pass values from .Net to Java Web serviceDhanushkahttp://www.blogger.com/profile/17951380919059282676noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-6540279523384613030.post-82638808167245834292009-07-13T23:26:00.000-07:002009-07-14T05:24:35.266-07:00How to pass data object from .Net to Java WebserviceThis is a simple guide that you should know about how to pass data object from .Net application to java web service.In this case we use Axis2 webservice angine to run those java web services.Important thing that you want know is that List obect cann't be passed between .Net and java webservice.If you want pass the List then you have to make array from list.array obect is allowed to pass.<br /><br />This is simple webservice written by java.<br /><br />public UserData getUserData(UserData userData){<br /> <br /> userData.setAge(50);<br /> return userData;<br /> }<br /><br /> In above method Userdata is Data object that can be hold all user information.<br /><br />You can reffer <a href="http://www.webservice-guru.blogspot.com"><span style="font-style: italic;">www.webservice-guru.blogspot.com </span></a>for how to know implementing .aar file for axis2.<br /><ul><li>After Implement the application we deploy the webservice in axis2 webservice engine and take the specific URL for that webservice.It shouldbe a url that is relavent wsdl file of the webservice</li></ul> Eg: http://localhost:8080/axis2/services/TCSService?wsdl<br /> http://<span style="font-weight: bold;">hostname</span>:8080/axis2/services/<span style="font-weight: bold;">webservicename</span>?wsdl<br /><br /><br />I will explain step by step that how to implement dot application for our above task.<br /><br /><ul><li>Create the new Project and new class on that project</li><li>Let see that we are going to access the following java web service method througth .Net application<br /></li></ul><ul><li>In dotnet application our namespace is clientForUserData</li><li>Then Right click on the project and add the web references to that object</li><li>Use the above URL and search the available web services.</li><li>Then It list the all webservices that is found </li><li>Give web service name and add the webservice to your dot net project.</li></ul> Eg: We give <span style="font-weight: bold;">testwebservice</span> as webservice name.<br /> and if our webservice is TCSService (That web service method has been declared)<br /><br /> Bellow is sample code to access that webservice<br /><br /> clientForUserData.testwebservice.TCSService tcs = new clientForUserData.TCSService.TCSService();<br /><br /> clientForUserData.TCSService.UserData ud = new clientForUserData.TCSService.UserData();<br /><br />ud.name = 'dhanushka';<br />ud.age = 26;<br /><br /> clientForUserData.TCSService.UserData updatedUD = new clientForUserData.TCSService.UserData();<br /><br />updatedUD = tcs.getUserData(ud);<br /><br /> Console.WriteLine(updatedUD.name );<br /> Console.WriteLine(updatedUD.age );<br /><br />Out put will be<br /><br />dhanushka<br />50Dhanushkahttp://www.blogger.com/profile/17951380919059282676noreply@blogger.com2