Web Service Integration Hands on Lab

Post on 22-Nov-2014

12 views 6 download

Transcript of Web Service Integration Hands on Lab

Domino 7/Visual Studio Web Services Integration: Hands on Labs

March, 2007

Gary Devendorf

Microsoft

ContentsExercise 1 - Creating your first Domino 7 web service.................................................................................3

Exercise 2 – Create a web service client for your web service.....................................................................8

Web Services Hands on Labs Page 2

Exercise 1 - Creating your first Domino 7 web service

1. Launch Domino Designer. User Name is “Jane Developer” and Password is “lotusnotes”

2. Open the database Workshop (workshop.nsf) on the server Neutron/MSDomino

3. Expand the Shared Code database entry and click the “New Web Service” button

Web Services Hands on Labs Page 3

4. In the property box for the web service enter your name in the “Name” text box (we are all working on the same database so we need to name the web services something unique).

5. In the “Port Type class” text box enter hello

6. Click on the security tab (the key) and select Allow Public Access users to use this web service.

Web Services Hands on Labs Page 4

7. In the Declarations section, add the code:

Class helloFunction hello_name(FirstName As String) As String

hello_name= "Hello " & FirstName & " this is from a Domino 7 web service"

End FunctionEnd Class

Web Services Hands on Labs Page 5

8. Save the web service.

9. Open a browser and locate the WSDL file for your new web service. The format for a Domino 7 WSDL URL is: <Server>/<database.nsf>/<web service name>?WSDL, so your URL will look like: http://www.msdomino.net/workshop.nsf/<Your Name>?wsdl In my case, the URL looks like this: http://www.msdomino.net/workshop.nsf/gary?wsdl

10. Leave this browser window open. We will need the URL later.

Web Services Hands on Labs Page 6

Exercise 2 – Create a web service client for your web service

1. Start Visual Studio by clicking Start-Microsoft Visual Studio 2005-Microsoft Visual Studio 2005

2. Select Project next to Create

3. In the New Project Dialog, select Visual Basic as the Project type4. Pick Window Application as the Template5. Enter My web service client in the Name field6. Click “OK”

Web Services Hands on Labs Page 7

7. When Form1 appears, expand its size by dragging its lower right corner.

8. Open the tool box.9. Drag one button and two textboxes onto the form. It should look something like this:

Web Services Hands on Labs Page 8

10. Select Button1 and locate its Text Property in the Properties window.11. Change the Text property value from Button1 to Call Web Service. You will need to

stretch the button so all the text will show.

Web Services Hands on Labs Page 9

12. Button1 now has the label Call Web Service. Double click the Go button to see the code for the click event. We will be entering code in the Button1_Click Sub.

13. Before we add code, we need to add a Web Reference for our Domino 7 web service. Right click on My web service client solution name to bring up a menu.

14. Select Add Web Reference.

Web Services Hands on Labs Page 10

15. Put the URL for your Domino 7 web service WSDL file in the “URL” text box and click “Go”

16. Notice the helloService with a Method called “HELLO_NAME()”

17. The default Web reference name is net.msdomino.www

Web Services Hands on Labs Page 11

18. Leave the default name and click the Add Reference button.

19. Notice that a web reference is now added to the Solution Explorer. These files were created from the WSDL content. Feel free to look at the files by double clicking on them. Adding a Web Reference is not unlike installing a component. Our program can now use the Web Reference class and its Methods or Properties as you will see.

Web Services Hands on Labs Page 12

20. In the Sub Button1_Click, add this code. Please type it to see the auto-complete functionality:

Dim MyDominoWS As New net.msdomino.www.helloService TextBox2.Text = MyDominoWS.HELLO_NAME(TextBox1.Text)

21. Then click on the triangle to start the debugger.

22. Enter your name in Textbox1 and click the Call Web Service button.

23. See the result in Textbox2.

24. Clear Textbox2 and click the button again. Notice any change in speed.

Web Services Hands on Labs Page 13

You have created a Domino 7 web service and a .NET windows client. Update your resume!

For an advanced bonus exercise, create a client application for this WSDL file:www.msdomino.net/orders.nsf/order_update?wsdl

You can find details at http://interoptips.com/forums/thread/107.aspx

Web Services Hands on Labs Page 14