Web Service Basics: Difference between revisions

Added procedure for adding WS client to non-visual component or adding manually
(Web Service Client stuff)
(Added procedure for adding WS client to non-visual component or adding manually)
 
(3 intermediate revisions by the same user not shown)
Line 2: Line 2:


===Creating a WebApp Project===
===Creating a WebApp Project===
In the [[Visual DataFlex Studio]], select <span style="color:blue; font-weight:bold">File => New => Project => Web Project</span> and follow the wizard's instructions.
In the [[Visual DataFlex Studio]], select <span style="color:midnightblue; font-weight:bold">File => New => Project => Web Project</span> and follow the wizard's instructions.
----
----


===Creating a Web Service Object===
===Creating a Web Service Object===
In the [[Visual DataFlex Studio]], select <span style="color:blue; font-weight:bold">File => New => Web Object => Web Service Object</span> and follow the wizard's instructions.
In the [[Visual DataFlex Studio]], select <span style="color:midnightblue; font-weight:bold">File => New => Web Object => Web Service Object</span> and follow the wizard's instructions.


The '''psDocumentation''' property will be automatically set to some default text, but you should replace this with a description of your own service, as this will appear in the [[WSDL]] <nowiki><documentation></nowiki> element describing the service.  There are several other properties which it now a good idea to set:
The '''psDocumentation''' property will be automatically set to some default text, but you should replace this with a description of your own service, as this will appear in the [[WSDL]] <nowiki><documentation></nowiki> element describing the service.  There are several other properties which it now a good idea to set:
Line 67: Line 67:
In the [[Code Explorer]] pane of the [[Visual DataFlex Studio]], right-click on the method (Function or Procedure) and select "'''Published'''" from the context menu.  This will cause (a) the "Published" context-menu item to subsequently appear "checked", (b) a globe to appear next to the method's icon in Code Explorer and (c) the two lines:
In the [[Code Explorer]] pane of the [[Visual DataFlex Studio]], right-click on the method (Function or Procedure) and select "'''Published'''" from the context menu.  This will cause (a) the "Published" context-menu item to subsequently appear "checked", (b) a globe to appear next to the method's icon in Code Explorer and (c) the two lines:


  <span style="color:blue;">{ Published = True  }
  <span style="color:midnightblue;">{ Published = True  }
  { Description = ""  }</span>
  { Description = ""  }</span>
  <span style="color:gray;">Function GoodsOrder PurchaseOrder Ord Returns OrderResponse</span>
  <span style="color:gray;">Function GoodsOrder PurchaseOrder Ord Returns OrderResponse</span>
Line 75: Line 75:


===Creating a Web Service Client===
===Creating a Web Service Client===
In order to create a [[Visual DataFlex]] web service client you must have access to the service's [[WSDL]] in some form.  This might be directly from the service itself - in [http://msdn2.microsoft.com/en-gb/webservices/default.aspx Microsoft .Net] or Visual DataFlex services this is the service's URL with "WSDL" appended as a [http://en.wikipedia.org/wiki/Query_string query string]: something like <span style="color:blue;"><nowiki>http://server/someService/service.wso?WSDL</nowiki></span> - or it might be an XML file provided by the service's developer or publisher which you have saved to a locally acessible file: <span style="color:blue;">C:\Services\Docs\someServiceWSDL.xml</span> - or it might be an XML/WSDL file statically published on a web site: <span style="color:blue;"><nowiki>http://server/services/wsdl/someService.xml</nowiki></span>.
In order to create a [[Visual DataFlex]] web service client you must have access to the service's [[WSDL]] in some form.  This might be directly from the service itself - in [http://msdn2.microsoft.com/en-gb/webservices/default.aspx Microsoft .Net] or Visual DataFlex services this is the service's URL with "WSDL" appended as a [http://en.wikipedia.org/wiki/Query_string query string]: something like <span style="color:midnightblue;"><nowiki>http://server/someService/service.wso?WSDL</nowiki></span> - or it might be an XML file provided by the service's developer or publisher which you have saved to a locally acessible file: <span style="color:midnightblue;">C:\Services\Docs\someServiceWSDL.xml</span> - or it might be an XML/WSDL file statically published on a web site: <span style="color:midnightblue;"><nowiki>http://server/services/wsdl/someService.xml</nowiki></span>.


In the [[Visual DataFlex Studio]], select <span style="color:blue; font-weight:bold">File => New => Class => Client Web Service Class</span>.  This will run the Web Service Client Class Generator.  Into its "WSDL URL" window paste (or type) the location (of whatever type) of the service's WSDL, then click the "Parse" button.  If this succeeds, then the "Generate Class" button will become available and can be clicked to create the client.  You should generally accept the default name and group.
In the [[Visual DataFlex Studio]], select <span style="color:midnightblue; font-weight:bold">File => New => Class => Client Web Service Class</span>.  This will run the Web Service Client Class Generator.  Into its "WSDL URL" window paste (or type) the location (of whatever type) of the service's WSDL, then click the "Parse" button.  If this succeeds, then the "Generate Class" button will become available and can be clicked to create the client.  You should generally accept the default name and group.


====Using a Web Service Client Class====
====Using a Web Service Client Class====
The class created above will (by default) then appear within the [[Visual DataFlex Studio]] on the [[Class Palette]] pane under the "Web Services" group.  From there it can be dragged and dropped onto a visual component (a [[View]] or whatever) in the Studio's "Designer", creating an object of that class within the component.
The class created above will (by default) then appear within the [[Visual DataFlex Studio]] on the [[Class Palette]] pane under the "Web Services" group.  From there it can be dragged and dropped onto a visual component (a [[View]] or whatever) in the Studio's "Designer", creating an object of that class within the component.
If you are working on a component that cannot be modelled in the Designer (either because it is a non-visual component like a Business Process or for some other reason) then you can still do the same thing: just drag the class onto the blank Designer page - it will be saying "'''No Objects to Model'''".
Or you can do it manually:
Use cWSServiceName.pkg
Object oCallItWhatYouWant is a cWSServiceName
End_Object  // oCallItWhatYouWant


This object - which we can think of as a "''stub''" or "''proxy''" for the web service itself - can then have its methods (which will map onto the ''operations'' of the service) invoked, passing them the appropriate data, to invoke the service itself, and receive any returned data from it.
This object - which we can think of as a "''stub''" or "''proxy''" for the web service itself - can then have its methods (which will map onto the ''operations'' of the service) invoked, passing them the appropriate data, to invoke the service itself, and receive any returned data from it.
[[Category:Web Services]] [[Category:Basics]]