New Message on dotNET User Group Hyd

Build a Visual Basic for Applications Web Service Client

Reply
  Reply to Sender   Recommend Message 1 in Discussion
From: johnsonsmithy2k2


This small info illustrates how you can add a Web service to a Visual Basic for Applications project and call a method in that service. The sample Web service you will reference is the EightBall Web service. You will write code that calls the Ask method in the EightBall Web Service; this method accepts a question as a parameter and returns a random answer.

Note:   For details on the EightBall Web service, visit http://www.gotdotnet.com/playground/services/EightBall.aspx.
While this small information shows how you can use a Web service in Microsoft Word, it does not incorporate any functionality that is specific to Word. Therefore, you can use these same steps in other Office applications Microsoft Excel, Microsoft PowerPoint or Microsoft Access to reference and call a Web service.

Start a new document in Microsoft Word.
On the Tools menu, click Macro, and then click Visual Basic Editor.
On the Tools menu in the Visual Basic Editor, click Web Service References. The Web Service References Tool 2.0 dialog box appears.
Add a reference to the EightBall Web Service:
Type "GotDotNet" for the Business Name and click Search. Your search criteria is submitted to the UDDI server; the results are shown in the Search Results window as a list of Web services and methods.
Select EightBallWS in the Search Results list and click Add. The proxy class for the Web Service is added to the project and named "clsws_EightBallWS".
On the Insert menu in the Visual Basic Editor, click Module to add a code module to your project. The code module is named "Module1" by default.
In Module1, type the following code:
Public Function AskEightBall(sQuestion as String) as String
   Dim wAnswer As New clsws_EightBallWS
   AskEightBall = wAnswer.wsm_Ask(sQuestion)
End Function

Public Sub TestEightBall()
   Dim sQuestion As String
   sQuestion = InputBox("What is your question for EightBall?")
   MsgBox AskEightBall(sQuestion)
End Sub
Place your cursor anywhere inside the TestEightBall procedure and press F5 to run it.
When prompted for a question, type "Does this sample work?" and click Okay.
The procedure creates a new instance of the Web service proxy class (clsws_EightBallWS) and calls the Ask method with your question as a string parameter. The Web service returns a random string as your answer.

I hope this information, help u all in ur development

regards,
smith
DISCLAIMER: The information contained in this message is intended only and solely for the addressed individual or entity indicated in this message and for the exclusive use of the said addressed individual or entity indicated in this message (or responsible for delivery of the message to such person) and may contain legally privileged and confidential information belonging to Tata Consultancy Services Limited. It must not be printed, read, copied, disclosed, forwarded, distributed or used (in whatsoever manner) by any person other than the addressee. Unauthorized use, disclosure or copying is strictly prohibited and may constitute unlawful act and can possibly attract legal action, civil and/or criminal. The contents of this message need not necessarily reflect or endorse the views of Tata Consultancy Services limited on any subject matter.
Any action taken or omitted to be taken based on this message is entirely at your risk and neither the originator of this message nor Tata Consultancy Services Limited takes any responsibility or liability towards the same. Opinions, conclusions and any other information contained in this message that do not relate to the official business of Tata Consultancy Services limited shall be understood as neither given nor endorsed by Tata Consultancy Services Limited or any affiliate of Tata Consultancy Services Limited. If you have received this message in error, you should destroy this message and may please notify the sender by e-mail.
Thank you.

View other groups in this category.

Click here!
Also on MSN:
Start Chatting | Listen to Music | House & Home | Try Online Dating | Daily Horoscopes

To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.

Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.

If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.

Reply via email to