Release 10.1A: OpenEdge Development:
Web Services

> ## ProcObject class factory methods

> This the Progress 4GL prototype for the persistent procedure that runs for the sample ProcObject class factory method, `CreatePO_CustomerOrder( )`:

> Progress 4GL prototype for a persistent procedure to implement a ProcObject
>     /* CustomerOrder.p */
>     DEFINE INPUT PARAMETER custNum AS INTEGER.

> Note: The parameter list for the persistent procedure that runs for the ProcObject class factory method is AppServer application dependent, and is the basis for creating the parameter list of the ProcObject class factory method. A persistent procedure can also be specified in ProxyGen to return a string value using the 4GL `RETURN` statement.

> This is a VB.NET declaration for the ProcObject class factory method, `CreatePO_CustomerOrder( )`:

> VB.NET prototype for the ProcObject CreatePO_CustomerOrder method
>     Public Function CreatePO_CustomerOrder
>                        (ByVal custNum As Integer) As String

> Note: This method maps to a persistent procedure that has been specified to return the string from the 4GL `RETURN-VALUE` function.

> The following lines of code:

> 1. Instantiate the ProcObject on the client, enabling access to its methods.

> 2. Call the CreatePO_CustomerOrder( ) method on the AppObject, `webService`, to create the ProcObject, CustomerOrder, on the WSA and run `CustomerOrder.p` persistently.

> 3. Copy the ProcObject ID to the ProcObject from the AppObject (`webService`) that creates the ProcObject.

> VB.NET client code to create the ProcObject, CustomerOrder
>     custOrder = New OrderSvc.CustomerOrderObj( )
>     custName = webService.CreatePO_CustomerOrder(3)
>     custOrder.CustomerOrderIDValue = webService.CustomerOrderIDValue

> This is a sample RPC/Encoded SOAP request that might be generated from invoking the `CreatePO_CustomerOrder( )` method to create the ProcObject, passing in a `custNum` value of 3:

> SOAP request to create ProcObject, CustomerOrder
>     <?xml version="1.0" encoding="utf-8" ?>
>     <soap:Envelope namespaces defined here...>
>        <soap:Header>
>           <q1:OrderInfoID id="h_id1"
>              xmlns:q1="urn:OrderSvc:OrderInfo">
>              <UUID xsi:type="xsd:string">2e62cab6b81150d5:167f64e:f295e997b0:
>              -8000;<OrderInfo|PX-000001|AO>;M/IryPm3piDcF/W5DsH4GA==</UUID>
>           </q1:OrderInfoID>
>        </soap:Header>
>        <soap:Body
>           soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
>           <q1:CreatePO_CustomerOrder xmlns:q1="urn:OrderSvc:OrderInfo">
>              <custNum xsi:type="xsd:int">3</custNum>
>           </q1:CreatePO_CustomerOrder>
>        </soap:Body>
>     </soap:Envelope>

> Note the value for the request highlighted in the example, especially the AppObject ID sent for the AppObject, `OrderInfo`, which is the parent of the ProcObject being created for customer number 3.

> This is a sample RPC/Encoded SOAP response that is generated by the WSA from this invocation of the `CreatePO_CustomerOrder( )` method:

> SOAP response from creating ProcObject, CustomerOrder
>     <?xml version="1.0" encoding="UTF-8" ?>
>     <soap:Envelope namespaces defined here...>
>        <soap:Header>
>           <t:CustomerOrderID xmlns:t="urn:OrderSvc:CustomerOrder"
>              soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
>              <UUID xsi:type="xsd:string">2e62cab6b81150d5:167f64e:f295e997b0:
>              -8000;<OrderInfo|PX-000002|PO>;G1Vc/vmohvLnwxQQXwA6Cg==</UUID>
>            </t:CustomerOrderID>
>        </soap:Header>
>     <soap:Body>
>        <ns1:CreatePO_CustomerOrderResponse xmlns:ns1="urn:OrderSvc:OrderInfo"
>           soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
>           <result xsi:type="xsd:string">Hoops</result>
>        </ns1:CreatePO_CustomerOrderResponse>
>        </soap:Body>
>     </soap:Envelope>

> Note the value returned for the `CustomerOrder` ProcObject ID highlighted in the example. The Web service returns this ProcObject ID even if it is session free, to allow the ProcObject to access its own AppServer session context.

> Thus, the SOAP response header returns the following ProcObject ID contained in the `CustomerOrderID` element:

>     2e62cab6b81150d5:167f64e:f295e997b0:-8000;<OrderInfo|PX-000002|PO>;G1Vc/vmoh
>     vLnwxQQXwA6Cg==

> Finally, note the 4GL `RETURN-VALUE`, `result`, returned from running the persistent procedure, which returns the customer name, `"Hoops"`.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095