Thursday, 22 August 2013

How to connect to a Syspro web service

Syspro has a very powerful and comprehensive set of API's exposed as web services. Here is a guide for how to use Syspro's web services.

Firstly, you need to connect to your Syspro web service’s server and get authenticated; in return, you will get a GUID.
To do this, you need to connect to the Logon method of this SOAP service:

Then you will can call an actual API to do something useful. In this example, we will send Syspro a finished goods receipt using the Transaction web service:

To call the Transaction web service, you need to pass these four parameters:

  1. UserId – use the GUID you obtained when you logged into SYSPRO as described above.
  2. BusinessObject – set it to be this string: INVTMR. There are many business objects that you can call via the Transaction web services; consult the Syspro business object documentation on the Syspro Support Zone for what web services you can use. 
  3. XMLParameters – this will be a fairly large string containing an XML document as described below.
  4. XMLIn – this will be a fairly large string containing an XML document; see below for example.

XMLParameters

Here is an example of the XMLParameters string:
<?xml version="1.0" encoding="Windows-1252"?>
<PostInvReceipts xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="INVTMR.XSD">
  <Parameters>
    <TransactionDate>2013-08-20</TransactionDate>
    <ApplyIfEntireDocumentValid>Y</ApplyIfEntireDocumentValid>
    <ValidateOnly>N</ValidateOnly>
    <ReturnDetailedReceipt>N</ReturnDetailedReceipt>
  </Parameters>
</PostInvReceipts>

XMLIn

Here is an example of the XMLIn string:
<?xml version="1.0" encoding="Windows-1252"?>
<PostInvReceipts xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="INVTMRDOC.XSD">
  <Item>
    <Warehouse>FG</Warehouse>
    <StockCode>A100</StockCode>
    <Quantity>1.000</Quantity>
    <Reference>Receipt</Reference>
  </Item>
</PostInvReceipts>

XMLOut

On successfully calling the web service, you should get a result like this:
<?xml version="1.0" encoding="Windows-1252"?>
<postinvreceipts Language='05' Language2='EN' CssStyle='' DecFormat='1' DateFormat='01' Role='01' Version='6.1.038' OperatorPrimaryRole='   '>
<Item>
<ItemNumber>000001</ItemNumber>
</Item>
<Key>
<JnlYear>2013</JnlYear>
<JnlMonth>05</JnlMonth>
<Journal>00032</Journal>
<EntryNumber>00001</EntryNumber>
<Warehouse>FG</Warehouse>
<GlJournal>
<GlYear>2013</GlYear>
<GlPeriod>05</GlPeriod>
<GlJournal>00230</GlJournal>
</GlJournal>
</Key>
<StatusOfItems>
<ItemsProcessed>1</ItemsProcessed>
<ItemsInvalid>0</ItemsInvalid>
</StatusOfItems>
</postinvreceipts>

XSD files

There are XSD files available for each Business Object. The XSD files are distributed with Syspro and found in the <Syspro-installation-directory>\Base\Schemas directory. These XSD files can be used to generate code objects. See this blog for more information on generating code objects from Syspro's XSD files: http://phildetail.blogspot.com.au/2014/04/how-to-use-xsd2code-for-syspros.html

No comments:

Post a Comment