Difference between revisions of "Web Services"

From SDU
Jump to: navigation, search
(Example Code: Using Webservice in VB.NET Web Application)
Line 1: Line 1:
[[Category:Integration]]
+
>[[Category:Integration]]
 
{{Global Header}}
 
{{Global Header}}
 
{{Global Announcement}}
 
{{Global Announcement}}
Line 7: Line 7:
 
#Start the front end.
 
#Start the front end.
 
#Go to Website menu and click “Add web reference”.
 
#Go to Website menu and click “Add web reference”.
#In the URL box provide the web service URL and click go. <nowiki>http://<hostname>:8080/axis/services/USD_R11_WebService?wsdl'''</nowiki>
+
#In the URL box provide the web service URL and click go. &lt;nowiki&gt;http://&lt;hostname&gt;:8080/axis/services/USD_R11_WebService?wsdl'''&lt;/nowiki&gt;
 
#We can find the methods being pulled out.
 
#We can find the methods being pulled out.
 
#Add the webreference with the name “WebReference”.
 
#Add the webreference with the name “WebReference”.
  
 
=== Step 2: Create an Object of the web reference ===
 
=== Step 2: Create an Object of the web reference ===
<source lang="javascript">Dim ws As New WebReference.USD_WebService</source>
+
&lt;source lang=&quot;javascript&quot;&gt;Dim ws As New WebReference.USD_WebService&lt;/source&gt;
  
 
=== Step 3: Specify the Correct web service URL ===
 
=== Step 3: Specify the Correct web service URL ===
<source lang="text">ws.Url = "http://<hostname>:8080/axis/services/USD_R11_WebService?wsdl"</source>
+
&lt;source lang=&quot;text&quot;&gt;ws.Url = &quot;http://&lt;hostname&gt;:8080/axis/services/USD_R11_WebService?wsdl&quot;&lt;/source&gt;
  
 
=== Step 4: Provide the username and password to get the sid value ===
 
=== Step 4: Provide the username and password to get the sid value ===
<source lang="javascript">Dim username, password As String
+
&lt;source lang=&quot;javascript&quot;&gt;Dim username, password As String
 
Dim sid As Integer
 
Dim sid As Integer
username = "analyst1"
+
username = &quot;analyst1&quot;
password = "123"
+
password = &quot;123&quot;
sid = ws.login(username, password)</source>
+
sid = ws.login(username, password)&lt;/source&gt;
 
where login is the method used to get the sid.
 
where login is the method used to get the sid.
  
 
=== Step 5: Get the User Handle ===
 
=== Step 5: Get the User Handle ===
<source lang="javascript">Dim userhandle As String
+
&lt;source lang=&quot;javascript&quot;&gt;Dim userhandle As String
userhandle = ws.getHandleForUserid(sid, username)</source>
+
userhandle = ws.getHandleForUserid(sid, username)&lt;/source&gt;
 
Where getHandleForUserid is the method
 
Where getHandleForUserid is the method
  
 
=== Step 6: Create a Request ===
 
=== Step 6: Create a Request ===
<source lang="javascript">Dim attrVal(5), attr(1), prop(1), persistent_id As String
+
&lt;source lang=&quot;javascript&quot;&gt;Dim attrVal(5), attr(1), prop(1), persistent_id As String
 
Dim requestHandle, requestNumber As String
 
Dim requestHandle, requestNumber As String
attrVal = New String() {"customer", userhandle, "category", "<category id>", "description", "Description here"}
+
attrVal = New String() {&quot;customer&quot;, userhandle, &quot;category&quot;, &quot;&lt;category id&gt;&quot;, &quot;description&quot;, &quot;Description here&quot;}
prop = New String() {""}
+
prop = New String() {&quot;&quot;}
 
attr = New String() {persistent_id}
 
attr = New String() {persistent_id}
requestHandle = ""
+
requestHandle = &quot;&quot;
requestNumber = ""
+
requestNumber = &quot;&quot;
ws.createRequest(sid, userhandle, attrVal, prop, "", attr, requestHandle, requestNumber)</source>
+
ws.createRequest(sid, userhandle, attrVal, prop, &quot;&quot;, attr, requestHandle, requestNumber)&lt;/source&gt;
  
 
=== Step 7: Create a Change Order ===
 
=== Step 7: Create a Change Order ===
<source lang="javascript">Dim attrVal(5), attr(1), prop(1), persistent_id As String
+
&lt;source lang=&quot;javascript&quot;&gt;Dim attrVal(5), attr(1), prop(1), persistent_id As String
 
Dim requestHandle, requestNumber As String
 
Dim requestHandle, requestNumber As String
attrVal = New String() {"requestor", userhandle, "category", "category id", "description", "description here"}
+
attrVal = New String() {&quot;requestor&quot;, userhandle, &quot;category&quot;, &quot;category id&quot;, &quot;description&quot;, &quot;description here&quot;}
prop = New String() {""}
+
prop = New String() {&quot;&quot;}
 
attr = New String() {cpersistent_id}
 
attr = New String() {cpersistent_id}
requestHandle = ""
+
requestHandle = &quot;&quot;
requestNumber = ""
+
requestNumber = &quot;&quot;
ws.createChangeOrder(sid, userhandle, attrVal, prop, "", cattr, requestHandle, requestNumber)</source>
+
ws.createChangeOrder(sid, userhandle, attrVal, prop, &quot;&quot;, cattr, requestHandle, requestNumber)&lt;/source&gt;
 
   
 
   
 
=== Step 8: Create a contact ===
 
=== Step 8: Create a contact ===
<source lang="javascript">Dim attrVal(5), attr(1), persistent_id As String
+
&lt;source lang=&quot;javascript&quot;&gt;Dim attrVal(5), attr(1), persistent_id As String
 
Dim contactHandle, contactNumber As String
 
Dim contactHandle, contactNumber As String
attrVal = New String() {"first_name","Mike", "last_name", "Tolland", "userid", "mike.tolland", "contact_num", "<Password here>", "email_address", "mike.tolland@abc.co.in", "phone_number", "00989876723"}
+
attrVal = New String() {&quot;first_name&quot;,&quot;Mike&quot;, &quot;last_name&quot;, &quot;Tolland&quot;, &quot;userid&quot;, &quot;mike.tolland&quot;, &quot;contact_num&quot;, &quot;&lt;Password here&gt;&quot;, &quot;email_address&quot;, &quot;mike.tolland@abc.co.in&quot;, &quot;phone_number&quot;, &quot;00989876723&quot;}
 
attr = New String() {persistent_id}
 
attr = New String() {persistent_id}
ws.createObject(sid, "cnt", attrVal, attr, contactHandle, contactNumber)</source>
+
ws.createObject(sid, &quot;cnt&quot;, attrVal, attr, contactHandle, contactNumber)&lt;/source&gt;
  
  
Line 61: Line 61:
 
== Creating Code for VB.net 2008 and R11 ==
 
== Creating Code for VB.net 2008 and R11 ==
 
=== Create object / login and return basic information ===
 
=== Create object / login and return basic information ===
<source lang="javascript">
+
&lt;source lang=&quot;javascript&quot;&gt;
  
 
         Dim sid As String
 
         Dim sid As String
 
         Dim uHandle As String
 
         Dim uHandle As String
 
         Dim b As New casoap.USD_WebServiceSoapClient
 
         Dim b As New casoap.USD_WebServiceSoapClient
         sid = b.login("Administrator", "password")
+
         sid = b.login(&quot;Administrator&quot;, &quot;password&quot;)
  
 
          
 
          
         Dim user As String = "devak01"
+
         Dim user As String = &quot;devak01&quot;
 
         uhandle = b.getHandleForUserid(sid, user)
 
         uhandle = b.getHandleForUserid(sid, user)
         Dim arryVals As String() = {"first_name", "last_name", "organization", _
+
         Dim arryVals As String() = {&quot;first_name&quot;, &quot;last_name&quot;, &quot;organization&quot;, _
                                     "organization.name", "admin_org.name", _
+
                                     &quot;organization.name&quot;, &quot;admin_org.name&quot;, _
                                     "group_list.length"}
+
                                     &quot;group_list.length&quot;}
 
         Dim arryValsresults As String = b.getObjectValues(sid, uHandle, arryVals)
 
         Dim arryValsresults As String = b.getObjectValues(sid, uHandle, arryVals)
</source>
+
&lt;/source&gt;
 
      
 
      
  
  
 
===Create a Asset / Hardware Configuration item ===
 
===Create a Asset / Hardware Configuration item ===
<source lang="javascript">
+
&lt;source lang=&quot;javascript&quot;&gt;
         Dim newexten As String = ""
+
         Dim newexten As String = &quot;&quot;
         Dim extenName As String = ""
+
         Dim extenName As String = &quot;&quot;
         Dim assethndle As String = ""
+
         Dim assethndle As String = &quot;&quot;
         Dim car As String = ""
+
         Dim car As String = &quot;&quot;
         Dim chgHandle As String = ""
+
         Dim chgHandle As String = &quot;&quot;
         Dim chgNum As String = ""
+
         Dim chgNum As String = &quot;&quot;
  
         Dim attrVal() As String = {"name", "hello2", "class", "grc:10000002"}
+
         Dim attrVal() As String = {&quot;name&quot;, &quot;hello2&quot;, &quot;class&quot;, &quot;grc:10000002&quot;}
 
         ReDim Preserve attrVal(3)
 
         ReDim Preserve attrVal(3)
         Dim persistent_id As String = "persistent_id"
+
         Dim persistent_id As String = &quot;persistent_id&quot;
 
         Dim attr() As String = {persistent_id}
 
         Dim attr() As String = {persistent_id}
 
         ReDim Preserve attr(0)
 
         ReDim Preserve attr(0)
  
 
         b.createAsset(sid, attrVal, attr, car, assethndle, newexten, extenName)
 
         b.createAsset(sid, attrVal, attr, car, assethndle, newexten, extenName)
</source>
+
&lt;/source&gt;
  
 
===Create a Change Order ===
 
===Create a Change Order ===
<source lang="javascript">
+
&lt;source lang=&quot;javascript&quot;&gt;
         Dim attrVal() As String = {"requestor", uHandle, "category", "5103", "description", "hello world"}
+
         Dim attrVal() As String = {&quot;requestor&quot;, uHandle, &quot;category&quot;, &quot;5103&quot;, &quot;description&quot;, &quot;hello world&quot;}
 
         ReDim Preserve attrVal(5)
 
         ReDim Preserve attrVal(5)
  
         Dim persistent_id As String = "persistent_id"
+
         Dim persistent_id As String = &quot;persistent_id&quot;
 
         Dim attr() As String = {persistent_id}
 
         Dim attr() As String = {persistent_id}
 
         ReDim Preserve attr(0)
 
         ReDim Preserve attr(0)
 
         Dim prop() As String = {}
 
         Dim prop() As String = {}
 
         ReDim Preserve prop(1)
 
         ReDim Preserve prop(1)
         Dim chgHandle As String = ""
+
         Dim chgHandle As String = &quot;&quot;
         Dim chgNum As String = ""
+
         Dim chgNum As String = &quot;&quot;
  
  
 
         b.createChangeOrder(sid, uHandle, attrVal, prop, _
 
         b.createChangeOrder(sid, uHandle, attrVal, prop, _
                             "", attr, chgHandle, chgNum)
+
                             &quot;&quot;, attr, chgHandle, chgNum)
</source>
+
&lt;/source&gt;
  
 
==How to Use Web Services==
 
==How to Use Web Services==
Line 124: Line 124:
 
Once your page is set up:
 
Once your page is set up:
  
Click the '''Website'''  > '''add reference'''  
+
Click the '''Website'''  &gt; '''add reference'''  
  
 
Enter the URL to the web services WSDL file, which is located at'
 
Enter the URL to the web services WSDL file, which is located at'
''http ://< your server>:8080/axis/services/USD_R11_WebService?wsdl'''
+
''http ://&lt; your server&gt;:8080/axis/services/USD_R11_WebService?wsdl'''
  
 
You might want to study a little XML and WSDL, but it isn't neccesary.   
 
You might want to study a little XML and WSDL, but it isn't neccesary.   
Line 137: Line 137:
  
 
Go to the Menu Bar and click  
 
Go to the Menu Bar and click  
Website > Add Web Reference (name it anything you want then click --> Add reference
+
Website &gt; Add Web Reference (name it anything you want then click --&gt; Add reference
  
 
And that is it!  
 
And that is it!  
Line 144: Line 144:
 
To use the web reference, create a new instance of the web service  
 
To use the web reference, create a new instance of the web service  
 
VB.Net Class program file
 
VB.Net Class program file
<source lang="javascript">
+
&lt;source lang=&quot;javascript&quot;&gt;
 
Partial Class tickets
 
Partial Class tickets
 
     Inherits System.Web.UI.UserControl
 
     Inherits System.Web.UI.UserControl
Line 154: Line 154:
 
To consume the service, call your first function
 
To consume the service, call your first function
 
ws.login(username, password)
 
ws.login(username, password)
</source>      
+
&lt;/source&gt;      
<source lang="javascript">
+
&lt;source lang=&quot;javascript&quot;&gt;
 
'the login function returns a system id value so...'
 
'the login function returns a system id value so...'
 
'lets rewrite the above code to look like the code below...'
 
'lets rewrite the above code to look like the code below...'
Line 161: Line 161:
 
Dim sid As String  
 
Dim sid As String  
 
sid = ws.login(username, password)
 
sid = ws.login(username, password)
</source>
+
&lt;/source&gt;
  
  
Line 167: Line 167:
 
  '''Here is a complete Code Snippit'''
 
  '''Here is a complete Code Snippit'''
  
<source lang="javascript">
+
&lt;source lang=&quot;javascript&quot;&gt;
 
Imports System.IO
 
Imports System.IO
 
Imports System.Xml
 
Imports System.Xml
 
Imports System.Xml.Serialization
 
Imports System.Xml.Serialization
Imports <ReferenceToWebServiceWSDL>
+
Imports &lt;ReferenceToWebServiceWSDL&gt;
 
Imports Connection
 
Imports Connection
  
Line 195: Line 195:
 
    
 
    
 
         Dim name = “Username”
 
         Dim name = “Username”
         Dim pass As String = "password"
+
         Dim pass As String = &quot;password&quot;
 
        
 
        
 
         sid = ws.login(name, pass)
 
         sid = ws.login(name, pass)
Line 206: Line 206:
 
     'Category Handle for the incident area'
 
     'Category Handle for the incident area'
 
     Try
 
     Try
xReturn = ws.doSelect(sid, "pcat", "sym = 'HARDWARE.PRINTER.SETUP'", 1, catAttrib)
+
xReturn = ws.doSelect(sid, &quot;pcat&quot;, &quot;sym = 'HARDWARE.PRINTER.SETUP'&quot;, 1, catAttrib)
 
             xDoc.LoadXml(xReturn)
 
             xDoc.LoadXml(xReturn)
             xHandle = xDoc.GetElementsByTagName("Handle")
+
             xHandle = xDoc.GetElementsByTagName(&quot;Handle&quot;)
 
             xResult = xHandle(0).InnerText
 
             xResult = xHandle(0).InnerText
 
             catHandle = xResult
 
             catHandle = xResult
 
         Catch ex As Exception
 
         Catch ex As Exception
             Response.Write("Exception caught while invoking an XML Web service.")
+
             Response.Write(&quot;Exception caught while invoking an XML Web service.&quot;)
 
         End Try
 
         End Try
  
Line 225: Line 225:
  
 
         Dim pri As String()
 
         Dim pri As String()
         pri = New String() {"pri:505", "pri:504", "pri:503", "pri:502", "pri:501", "pri:500"}
+
         pri = New String() {&quot;pri:505&quot;, &quot;pri:504&quot;, &quot;pri:503&quot;, &quot;pri:502&quot;, &quot;pri:501&quot;, &quot;pri:500&quot;}
  
 
         'Set the priority number Testing only'
 
         'Set the priority number Testing only'
Line 231: Line 231:
  
  
         attrib = New String() {"customer", userhandle, "priority", "pri:502", "category", _  
+
         attrib = New String() {&quot;customer&quot;, userhandle, &quot;priority&quot;, &quot;pri:502&quot;, &quot;category&quot;, _  
                                                                           pcatResult, "description", "Test"}
+
                                                                           pcatResult, &quot;description&quot;, &quot;Test&quot;}
         prop = New String() {""}
+
         prop = New String() {&quot;&quot;}
 
         attr = New String() {persistent_id}
 
         attr = New String() {persistent_id}
         requestHandle = ""
+
         requestHandle = &quot;&quot;
         requestNumber = ""
+
         requestNumber = &quot;&quot;
  
 
         'Create the ticket'
 
         'Create the ticket'
 
         'Including a try catch block for catching an error dealing with additional fields'
 
         'Including a try catch block for catching an error dealing with additional fields'
         ws.createRequest(sid, userhandle, attrVal, prop, "", attr, requestHandle, requestNumber)
+
         ws.createRequest(sid, userhandle, attrVal, prop, &quot;&quot;, attr, requestHandle, requestNumber)
  
 
         'I need to close the connection.'
 
         'I need to close the connection.'
Line 250: Line 250:
  
 
         ws.Url =  _
 
         ws.Url =  _
           "http://<yourServerName>:8080/axis/services/USD_R11_WebService?wsdl"
+
           &quot;http://&lt;yourServerName&gt;:8080/axis/services/USD_R11_WebService?wsdl&quot;
 
     End Sub
 
     End Sub
 
End Class
 
End Class
</source>
+
&lt;/source&gt;
  
 
== ASP Web Project ==
 
== ASP Web Project ==
 
Create an ASP .NET Web Project
 
Create an ASP .NET Web Project
Below is a sample ASP Page. Copy and paste the code Between the <Form></Form> tags.
+
Below is a sample ASP Page. Copy and paste the code Between the &lt;Form&gt;&lt;/Form&gt; tags.
  
<source lang="javascript">
+
&lt;source lang=&quot;javascript&quot;&gt;
  
  
  
 
'default.aspx'
 
'default.aspx'
<asp:Label id="replay" runat="server" />
+
&lt;asp:Label id=&quot;replay&quot; runat=&quot;server&quot; /&gt;
  
 
'Get the User Name and Password'
 
'Get the User Name and Password'
<input type="text" id="username" runat="server" />
+
&lt;input type=&quot;text&quot; id=&quot;username&quot; runat=&quot;server&quot; /&gt;
<input type="password" id="password" runat="server" />
+
&lt;input type=&quot;password&quot; id=&quot;password&quot; runat=&quot;server&quot; /&gt;
  
  
</source>
+
&lt;/source&gt;
  
 
== Having Fun ==
 
== Having Fun ==
Line 279: Line 279:
 
When the user logs in correctly the form will disapear and s\he will be greeted by there username
 
When the user logs in correctly the form will disapear and s\he will be greeted by there username
  
<source lang="javascript">
+
&lt;source lang=&quot;javascript&quot;&gt;
  
 
'in your default.aspx.vb file'
 
'in your default.aspx.vb file'
Line 292: Line 292:
  
 
'Say Hello to you user'
 
'Say Hello to you user'
replay.Text = " Welcome " & username.Text
+
replay.Text = &quot; Welcome &quot; &amp; username.Text
  
</source>
+
&lt;/source&gt;
  
  
 
''If you copy and paste the code, you need to remove the aphostrophy at the end of each comment only.  
 
''If you copy and paste the code, you need to remove the aphostrophy at the end of each comment only.  
To do this just use your find and replace function. MenuBar Item Edit > Find and Replace --> Quck Replace > find What: ' . Next, Replace With  <- test box insert a space. You'll have to do this one-by-one so not to uncomment the whole line.''
+
To do this just use your find and replace function. MenuBar Item Edit &gt; Find and Replace --&gt; Quck Replace &gt; find What: ' . Next, Replace With  &lt;- test box insert a space. You'll have to do this one-by-one so not to uncomment the whole line.''
 +
 
 +
----
 +
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 +
----
 +
=[http://apyholidev.co.cc Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly]=
 +
----
 +
=[http://apyholidev.co.cc CLICK HERE]=
 +
----
 +
</div>

Revision as of 00:32, 18 November 2010

>

To make corrections or additions to this article, select the edit tab above.
To discuss or ask questions about this article, select the discussion tab above.

Create a Request, Change Order and Contact through Web Services via VB

Step1: Create a web reference in the front end.

  1. Start the front end.
  2. Go to Website menu and click “Add web reference”.
  3. In the URL box provide the web service URL and click go. <nowiki>http://<hostname>:8080/axis/services/USD_R11_WebService?wsdl</nowiki>
  4. We can find the methods being pulled out.
  5. Add the webreference with the name “WebReference”.

Step 2: Create an Object of the web reference

<source lang="javascript">Dim ws As New WebReference.USD_WebService</source>

Step 3: Specify the Correct web service URL

<source lang="text">ws.Url = "http://<hostname>:8080/axis/services/USD_R11_WebService?wsdl"</source>

Step 4: Provide the username and password to get the sid value

<source lang="javascript">Dim username, password As String Dim sid As Integer username = "analyst1" password = "123" sid = ws.login(username, password)</source> where login is the method used to get the sid.

Step 5: Get the User Handle

<source lang="javascript">Dim userhandle As String userhandle = ws.getHandleForUserid(sid, username)</source> Where getHandleForUserid is the method

Step 6: Create a Request

<source lang="javascript">Dim attrVal(5), attr(1), prop(1), persistent_id As String Dim requestHandle, requestNumber As String attrVal = New String() {"customer", userhandle, "category", "<category id>", "description", "Description here"} prop = New String() {""} attr = New String() {persistent_id} requestHandle = "" requestNumber = "" ws.createRequest(sid, userhandle, attrVal, prop, "", attr, requestHandle, requestNumber)</source>

Step 7: Create a Change Order

<source lang="javascript">Dim attrVal(5), attr(1), prop(1), persistent_id As String Dim requestHandle, requestNumber As String attrVal = New String() {"requestor", userhandle, "category", "category id", "description", "description here"} prop = New String() {""} attr = New String() {cpersistent_id} requestHandle = "" requestNumber = "" ws.createChangeOrder(sid, userhandle, attrVal, prop, "", cattr, requestHandle, requestNumber)</source>

Step 8: Create a contact

<source lang="javascript">Dim attrVal(5), attr(1), persistent_id As String Dim contactHandle, contactNumber As String attrVal = New String() {"first_name","Mike", "last_name", "Tolland", "userid", "mike.tolland", "contact_num", "<Password here>", "email_address", "mike.tolland@abc.co.in", "phone_number", "00989876723"} attr = New String() {persistent_id} ws.createObject(sid, "cnt", attrVal, attr, contactHandle, contactNumber)</source>


Creating Code for VB.net 2008 and R11

Create object / login and return basic information

<source lang="javascript">

       Dim sid As String
       Dim uHandle As String
       Dim b As New casoap.USD_WebServiceSoapClient
       sid = b.login("Administrator", "password")


       Dim user As String = "devak01"
       uhandle = b.getHandleForUserid(sid, user)
       Dim arryVals As String() = {"first_name", "last_name", "organization", _
                                   "organization.name", "admin_org.name", _
                                   "group_list.length"}
       Dim arryValsresults As String = b.getObjectValues(sid, uHandle, arryVals)

</source>


Create a Asset / Hardware Configuration item

<source lang="javascript">

       Dim newexten As String = ""
       Dim extenName As String = ""
       Dim assethndle As String = ""
       Dim car As String = ""
       Dim chgHandle As String = ""
       Dim chgNum As String = ""
       Dim attrVal() As String = {"name", "hello2", "class", "grc:10000002"}
       ReDim Preserve attrVal(3)
       Dim persistent_id As String = "persistent_id"
       Dim attr() As String = {persistent_id}
       ReDim Preserve attr(0)
       b.createAsset(sid, attrVal, attr, car, assethndle, newexten, extenName)

</source>

Create a Change Order

<source lang="javascript">

       Dim attrVal() As String = {"requestor", uHandle, "category", "5103", "description", "hello world"}
       ReDim Preserve attrVal(5)
       Dim persistent_id As String = "persistent_id"
       Dim attr() As String = {persistent_id}
       ReDim Preserve attr(0)
       Dim prop() As String = {}
       ReDim Preserve prop(1)
       Dim chgHandle As String = ""
       Dim chgNum As String = ""


       b.createChangeOrder(sid, uHandle, attrVal, prop, _
                           "", attr, chgHandle, chgNum)

</source>

How to Use Web Services

I am using Visual Web Developer Express.Net. It is free and easy to use. To consume the USD web services, create a new web application.

Now is time to get to work

Once your page is set up:

Click the Website > add reference

Enter the URL to the web services WSDL file, which is located at' http ://< your server>:8080/axis/services/USD_R11_WebService?wsdl'

You might want to study a little XML and WSDL, but it isn't neccesary. Look up the topic, Consume or Consuming Web Services.

Quick Reference

Consuming Web service With Visual Studio/ Express Web Developer

Go to the Menu Bar and click Website > Add Web Reference (name it anything you want then click --> Add reference

And that is it!


To use the web reference, create a new instance of the web service VB.Net Class program file <source lang="javascript"> Partial Class tickets

   Inherits System.Web.UI.UserControl
   Private ws As New USD_WebService
                     .
                     .
              .

To consume the service, call your first function ws.login(username, password) </source> <source lang="javascript"> 'the login function returns a system id value so...' 'lets rewrite the above code to look like the code below...'

Dim sid As String sid = ws.login(username, password) </source>


Example Code: Using Webservice in VB.NET Web Application

Here is a complete Code Snippit

<source lang="javascript"> Imports System.IO Imports System.Xml Imports System.Xml.Serialization Imports <ReferenceToWebServiceWSDL> Imports Connection

Partial Class _Default

   Inherits System.Web.UI.Page
   Dim ws As New USD_WebService
   Dim sid As String
   Dim userhandle, username, password As String
   Dim attrVal(5), attr(0), prop(0) As String
   Dim requestHandle, requestNumber As String
   Dim persistent_id As String
   Dim catAttrib(5) As String
   Dim xmlReturn As String
   Dim pcatHandle As XmlNodeList
   Dim xDoc As XmlDocument = New XmlDocument()
   Dim pcatResult As String
   'Class for handling the button click submit'
   Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click
 
       Dim name = “Username”
       Dim pass As String = "password"
      
       sid = ws.login(name, pass)
       
       'get the Handle for the userid'
   userhandle = ws.getHandleForUserid(sid,name)
   'Get The Category Attributes'
    catAttrib = New String(0) {}
   'Category Handle for the incident area'
    Try

xReturn = ws.doSelect(sid, "pcat", "sym = 'HARDWARE.PRINTER.SETUP'", 1, catAttrib)

           xDoc.LoadXml(xReturn)
           xHandle = xDoc.GetElementsByTagName("Handle")
           xResult = xHandle(0).InnerText
           catHandle = xResult
       Catch ex As Exception
           Response.Write("Exception caught while invoking an XML Web service.")
       End Try
 'Priority handle for the ticeket'
       'sym = priority.Value'
       '505	0	0	None Priority unassigned'	
       '500	0	1	5	LOW Priority	
       '501	0	2	4	MEDIUM-LOW Priority	
       '502	0	3	3	MEDIUM Priority	
       '503	0	4	2	MEDIUM-HIGH Priority	
       '504	0	5	1	HIGH Priority	
       Dim pri As String()
       pri = New String() {"pri:505", "pri:504", "pri:503", "pri:502", "pri:501", "pri:500"}
       'Set the priority number Testing only'
       priority_number = 1


       attrib = New String() {"customer", userhandle, "priority", "pri:502", "category", _ 
                                                                         pcatResult, "description", "Test"}
       prop = New String() {""}
       attr = New String() {persistent_id}
       requestHandle = ""
       requestNumber = ""
       'Create the ticket'
       'Including a try catch block for catching an error dealing with additional fields'
        ws.createRequest(sid, userhandle, attrVal, prop, "", attr, requestHandle, requestNumber)
       'I need to close the connection.'
       ws.logout()
   End Sub
  

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

       ws.Url =  _
          "http://<yourServerName>:8080/axis/services/USD_R11_WebService?wsdl"
   End Sub

End Class </source>

ASP Web Project

Create an ASP .NET Web Project Below is a sample ASP Page. Copy and paste the code Between the <Form></Form> tags.

<source lang="javascript">


'default.aspx' <asp:Label id="replay" runat="server" />

'Get the User Name and Password' <input type="text" id="username" runat="server" /> <input type="password" id="password" runat="server" />


</source>

Having Fun

Pop the code below in your VB file. When the user logs in correctly the form will disapear and s\he will be greeted by there username

<source lang="javascript">

'in your default.aspx.vb file' Dim ws As New USD_WebService

'Login' ws.login(username.Text, password.Text)

'Just for fun hide input areas' username.Visable = false password.Visalbe = false

'Say Hello to you user' replay.Text = " Welcome " & username.Text

</source>


If you copy and paste the code, you need to remove the aphostrophy at the end of each comment only. To do this just use your find and replace function. MenuBar Item Edit > Find and Replace --> Quck Replace > find What: ' . Next, Replace With <- test box insert a space. You'll have to do this one-by-one so not to uncomment the whole line.



Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly


CLICK HERE