# SOAP request from Natural

**URL:** <https://techcommunity.softwareag.com/t/soap-request-from-natural/60228>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-Web-and-XML-Technology, Natural-on-Windows-Unix\
**Created:** [September 30, 2005, 6:59pm UTC](https://techcommunity.softwareag.com/t/soap-request-from-natural/60228 "2005-09-30T18:59:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hans\_Henrik](https://avatars.discourse-cdn.com/v4/letter/h/f0a364/32.png) [@Hans\_Henrik](https://techcommunity.softwareag.com/u/Hans_Henrik)\
**Post date:** [September 30, 2005, 6:59pm UTC](https://techcommunity.softwareag.com/t/soap-request-from-natural/60228/1 "2005-09-30T18:59:22Z")

</div>

I got a question about how to access a SOAP Web Service from Natural. I did not know, I never tried it. So I decided to try to access a Web Service on the Internet from Natural 6.1.1 on Windows XP.

First I looked for some services to call and I found the site: [www.webservicex.net](http://www.webservicex.net).

Then my problems really started how do I specify the proxy host to Natural? How to do a POST with DATA ALL.  
With the help from Michael Muenster I learned that Natural on Windows get the proxy name and port from Windows. Natural UNIX and Natural 4.2 on mainframe use a Natural parameter.  
I also found information in the Natural Documentation about the header Request-Method.

Now it works 😃 I have enclosed an example:

```auto
define data local
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 (a20)
*
1 #active_name (a16)
1 #Reply
  2 Symbol (a10)
  2 Last (a10)
  2 Date (a10)
  2 Time (a7)
  2 Change (a10)
  2 Open (a10)
  2 High (a10)
  2 Low (a10)
  2 Volume (a10)
  2 MktCap (a10)
  2 PreviousClose (a10)
  2 PercentageChange (a10)
  2 AnnRange (a20)
  2 Earns (a10)
  2 P-E (a10)
  2 Name (a20)
end-define
*
input // 'Symbol:' Symbol //
   'Example: SOW.DE(Software AG), IBM, MSFT(Microsoft)'
*
compress
  '<?xml version="1.0" encoding="UTF-8" ?>' -
  '<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" ' -
  'xmlns:xmm="http://namespace.softwareag.com/entirex/xml/mapping" ' -
  'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' -
  'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' -
  'xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">' -
  '<SOAP-ENV:Header></SOAP-ENV:Header>' -
  '<SOAP-ENV:Body>' -
  '<m:GetQuote xmlns="http://www.webserviceX.NET/" xmlns:m="http://www.webserviceX.NET/">' -
  '<symbol>'
  symbol
  '</symbol></m:GetQuote></SOAP-ENV:Body></SOAP-ENV:Envelope>' into
  #request leaving no
*
* For more information about the service have a look at:
* http://www.webservicex.net.
*
request document from 'http://www.webservicex.net/stockquote.asmx'
  with
    header
      name 'Request-Method' value 'POST'
      name 'Content-Type' value 'text/xml'
      name 'SOAPAction' value 'http://www.webserviceX.NET/GetQuote'
    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 '>'
*
  parse xml #response into path #path name #name value #value
    decide on first value of *parse-type
      value 'T'
        #active_name := #name
      value '$'
        decide on first value of #active_name
          value 'Symbol' ; #reply.symbol := #value
          value 'Last' ; #reply.last := #value
          value 'Date' ; #reply.date := #value
          value 'Time' ; #reply.time := #value
          value 'Change' ; #reply.change := #value
          value 'Open' ; #reply.open := #value
          value 'High' ; #reply.high := #value
          value 'Low' ; #reply.low := #value
          value 'Volume' ; #reply.volume := #value
          value 'MktCap' ; #reply.mktcap := #value
          value 'PreviousClose' ; #reply.PreviousClose := #value
          value 'PercentageChange'; #reply.PercentageChange := #value
          value 'AnnRange' ; #reply.annrange := #value
          value 'Earns' ; #reply.earns := #value
          value 'P-E' ; #reply.P-E := #value
          value 'Name' ; #reply.name := #value
          none value ignore
        end-decide
      none value ignore
    end-decide
  end-parse
*
  write #Reply.symbol '-' #reply.name 62T #reply.date #reply.time //
    'Last ..................' #reply.last /
    'Change ................' #reply.change /
    'Open ..................' #reply.open /
    'High ..................' #reply.high /
    'Low ...................' #reply.low /
    'Volume ................' #reply.volume /
    'MktCap ................' #reply.mktcap /
    'Previous Close ........' #reply.previousclose /
    'Percentage Change .....' #reply.percentageChange /
    'Ann Range .............' #reply.annrange /
    'Earns .................' #reply.earns /
    'P-E ...................' #reply.p-e
*
else
  write // 'HTTP-Status:' http-status-text //
end-if
*
end
```

---

<div class="post-metadata">

**Author:** ![anon29934956](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@anon29934956](https://techcommunity.softwareag.com/u/anon29934956)\
**Post date:** [October 5, 2005, 1:30pm UTC](https://techcommunity.softwareag.com/t/soap-request-from-natural/60228/2 "2005-10-05T13:30:44Z")

</div>

Thank you for providing this very useful example.

Accessing the SOAP service requires setting the Request-Method to ‘POST’ and the Content-Type to ‘text/xml’

> [@](#):
>
> request document from ‘[http://www.webservicex.net/stockquote.asmx](http://www.webservicex.net/stockquote.asmx)’  
> with  
> header  
> name ‘Request-Method’ value ‘POST’  
> name ‘Content-Type’ value ‘text/xml’   
> name ‘SOAPAction’ value ‘[http://www.webserviceX.NET/GetQuote](http://www.webserviceX.NET/GetQuote)’  
> data all #request  
> return  
> header name ’ ’ value http-status-text  
> page #response  
> response #rc

---

<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:40pm UTC](https://techcommunity.softwareag.com/t/soap-request-from-natural/60228/3 "2021-04-02T14:40:18Z")

</div>


