Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
mvl
New Contributor

How to reach FortiManager XML API with Perl?

Hello there,

 

I am following this XML API reference document: http://docs.fortinet.com/uploaded/files/3696/FortiManager%205.4.1%20XML%20API%20Reference.pdf

 

On page 12, there is an example SOAP request to get the session ID:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:r20="http://r200806.ws.fmg.fortinet.com/">
 <soapenv:Header/>
 <soapenv:Body>
  <r20:execSysLoginUser>
   <data>
    <user>xxxxx</user>
    <passwd>xxxxx</passwd>
   </data>
  </r20:execSysLoginUser>
 </soapenv:Body>
</soapenv:Envelope>

 

I am able to get an answer when I do this directly from command line of my server:

openssl s_client -host FMG-VM0A16004441 -port 8080
POST /execSysLoginUser HTTP/1.1
Host: FMG-VM0A16004441
Content-Type: application/xml
Content-Length: 308

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:r20="http://r200806.ws.fmg.fortinet.com/">
<soapenv:Header/>
<soapenv:Body>
<r20:execSysLoginUser>
<data>
<user>xxxxx</user>
<passwd>xxxxx</passwd>
</data>
</r20:execSysLoginUser>
</soapenv:Body>
</soapenv:Envelope>

 

HTTP/1.1 200 OK
Server: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://jaxb.dev.java.net/array" xmlns:ns3="http://r200806.ws.fmg.fortinet.com/">

<SOAP-ENV:Header></SOAP-ENV:Header>

<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<ns3:execSysLoginUserResponse>

<status>

<errorCode>0</errorCode>

<errorMsg>OK</errorMsg>

</status>

<session>xSE3D11pS2o5KaEHe2V2Fn/22lP2Cw2O69Tnxgyx59S4oCkmnq/pnUB0+4x66DrVpw4YiClLi69upbU5XF2FMgmx3IvpEuo2</session>

</ns3:execSysLoginUserResponse>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

 

But I am struggling to put this into a Perl script.

Surely I could send the whole XML as a HTTP request and then parse the answer with XML::Simple or something similar.

But I am sure there must be an easier way. The WSDL is available directly on FortiManager (for example under [link]https://fortimanager_ip:8080/wsdl/sys/).[/link]

 

I found a lot of different information online, usually pointing to modules like SOAP::Lite and SOAP::WSDL, but nothing really worked.

 

Isn't there a way in Perl to just take the WSDL document and load it and then simply reference the methods/functions/elements based on the WSDL definition?

 

Any idea how to convert the WSDL/SOAP into an effective Perl code would be much much appreciated.

 

Thanks,

Martin

 

 

 

0 REPLIES 0
Labels
Top Kudoed Authors