# Natural Web service calls

**URL:** <https://techcommunity.softwareag.com/t/natural-web-service-calls/96485>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-News-and-General-Topics\
**Created:** [March 15, 2011, 11:38am UTC](https://techcommunity.softwareag.com/t/natural-web-service-calls/96485 "2011-03-15T11:38:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![splsemo](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@splsemo](https://techcommunity.softwareag.com/u/splsemo)\
**Post date:** [March 15, 2011, 11:38am UTC](https://techcommunity.softwareag.com/t/natural-web-service-calls/96485/1 "2011-03-15T11:38:15Z")

</div>

Written a few WS clients in normal Natural using the REQUEST DOCUMENT command and they work quite well , but now I have a requirement to call a Web Service that uses HTTP digest security (not basic HTTP Auth).

Does anyone know of a way to impliment this using the REQUEST DOCUMENT command in natural?

Help/comments/wild speculations gratefully accepted.

example program :

\*\*NAM: XWS018N

\*\* :

\*\*FNC: Natural WS client vir SMS send

\*\*FNC: KONTROLE sleutel vir hierdie WS is: SMSSEND

\*\*FNC:

\*\* :

\*\*HST: (suggested content - name or id, date, request no., description)

\*\*HST: ARSEM, 2009/10/23 - Skryf

\*\*FBX: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

DEFINE DATA

PARAMETER

01 #MSG-TYPE (A20)

01 #P-NUMBER (A20)

01 #P-MESSAGE (A150)

01 #XWS-ERROR-CODE (N8)

01 #XWS-ERROR-TEXT (A250)

LOCAL

01 XWS-KONTROLE VIEW OF XWS-KONTROLE

02 KONTROLE-SLEUTEL

02 XWS-EINDPUNT

01 #WS-ENDPOINT (A100)

- 

1 #request (a) dynamic

1 #response (a) dynamic

1 #rc (i4)

- 

1 #path (a) dynamic

1 #name (a) dynamic

1 #value (a) dynamic

- 

1 http-status-text (a200)

- 

1 #i (n6)

1 #active\_name (a16)

1 #REPLY

2 OK (A1)

2 ERRORCODE (A10)

2 ERRORTEXT (A250)

END-DEFINE

- 

\*\* Get WS Endpoint

FIND(1) XWS-KONTROLE WITH KONTROLE-SLEUTEL = ‘SMSSEND’

IF NO RECORDS FOUND

```
ASSIGN #XWS-ERROR-CODE = 80

ASSIGN #XWS-ERROR-TEXT = 'NO CONTROL RECORD FOUND'

ESCAPE ROUTINE

```

END-NOREC

ASSIGN #WS-ENDPOINT = XWS-KONTROLE.XWS-EINDPUNT

END-FIND

- 

COMPRESS

‘\<soap:Envelope xmlns:soap=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”\>’

‘\<soap:Body xmlns:ns1=“http://elmarwssendsmsws\_v2/types/”\>’

‘ns1:sendSMSElement’

‘ns1:msgType’ #MSG-TYPE ’ \</ns1:msgType\>’

‘ns1:passwordwjw7w34\</ns1:password\>’

‘ns1:number’ #P-NUMBER ‘\</ns1:number\>’

‘ns1:message’ #P-MESSAGE ‘\</ns1:message\>’

‘\</ns1:sendSMSElement\>’

‘\</soap:Body\>’

‘\</soap:Envelope\>’

INTO

#request leaving no

- 
- For more information about the service have a look at:

- [http://www.webservicex.net](http://www.webservicex.net).

- 

request document from #WS-ENDPOINT

with

```
header

  name 'Request-Method' value 'POST'

  name 'Content-Type' value 'text/xml; charset=UTF-8'

  name 'SOAPAction' value ' '

data all #request

```

return

```
header name ' ' value http-status-text

page #response

```

response #rc

- 

if #rc = 200

examine #response for ‘\<’ replace with ‘\<’

examine #response for ‘\>’ replace with ‘\>’

examine #response for ‘&’ replace with ‘&’

examine #response for ‘'’ replace with “'”

- 

parse xml #response into path #path name #name value #value

```
decide on first value of *parse-type

  value 'T'

    #active_name := #name

  value '$'

```

\*\* display #active\_name #value (al=60)

```
    DECIDE ON FIRST VALUE OF #ACTIVE_NAME

      VALUE 'ns0:errorCode' ; #REPLY.ERRORCODE := #VALUE

      VALUE 'ns0:errorText' ; #REPLY.ERRORTEXT := #VALUE

      NONE VALUE IGNORE

    END-DECIDE

  NONE VALUE IGNORE

END-DECIDE

```

END-PARSE

#XWS-ERROR-CODE := VAL(#REPLY.ERRORCODE)

#XWS-ERROR-TEXT := #REPLY.ERRORTEXT

- 

ELSE

#XWS-ERROR-CODE := #RC

#XWS-ERROR-TEXT := http-status-text

END-IF

- 

END

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:59pm UTC](https://techcommunity.softwareag.com/t/natural-web-service-calls/96485/2 "2021-04-02T14:59:56Z")

</div>


