Web Services - Purchase Order
1. Module Overview
General information about the NetBaron-Web Services interface is provided in a separate document, available from NetBaron support upon request. This document only describes the Purchase Order Web Services module, which enables access to NetBaron's Batch Selling Bill from external services.
The module allows retrieving purchase order data and creating new purchase orders. The interfaces do not support multiple currencies; only EUR is supported.
Error handling must be integrated into the interfaces in case of connection interruptions.
1.1 Usage Examples
Retrieve purchase orders using a given identifier
Add new purchase orders
2. Technical Information
2.1 Service Information
Address: | https://server/ws/purchaseorder If a second parallel interface has been enabled, the interface number must be specified in addition to the address to ensure that the interface is called from the correct endpoint; otherwise, authentication will fail. For example: |
Authentication: | Organization and the organization-specific Web Services password |
The character set used: | UTF-8 |
Available methods: | GET / PUT |
Type of request: | Object |
Type of response: | Object |
2.2 Request content (GET)
OrderIdentifierIds is mandatory if no other search criteria are specified.
SellerIdentifierId is mandatory if UseSellerIdentifierId is true.
GetOnlyComplementaryDelivery limits the search to orders that have rows in backorder. The search is restricted to orders in the Ordered status.
UseSellerIdentifierId limits the search to the supplier specified by SellerIdentifierId. When used together with the GetOnlyComplementaryDelivery parameter, it returns backorders from the specified supplier.
OrderIdentifierIds always restricts the search to the specified orders, even when used in conjunction with GetOnlyComplementaryDelivery and UseSellerIdentifierId parameters.
Element | Type | Use | Default | Definition |
GetSellerPartyDetails | boolean | Control message | FALSE | Seller details |
GetInvoiceRecipientPartyDetails | boolean | Control message | FALSE | Payer details |
GetBuyerPartyDetails | boolean | Control message | FALSE | Buyer details |
GetDeliveryPartyDetails | boolean | Control message | FALSE | Delivery address details |
GetDeliveryDetails | boolean | Control message | FALSE | Delivery details |
GetInvoiceDetails | boolean | Control message | FALSE | Purchase order details |
GetInvoiceFreeText | boolean | Control message | FALSE | Purchase order free text |
GetInvoiceRow | boolean | Control message | FALSE | Order rows |
GetOnlyComplementaryDelivery | boolean | Control message | FALSE | Orders with rows in backorder |
UseSellerIdentifierId | boolean | Control message | FALSE | Used to filter the search by the supplier ID |
OrderIdentifierIds | object | Search criteria | The purchase orders to be retrieved | |
SellerIdentifierId | int(11) | Search criteria | Supplier ID | |
GetOrders | boolean | Search criteria | FALSE | Returns the purchase orders as a list |
Filters | object | Search criteria | Filters the list of purchase orders when GetOrders is used |
2.2.1 OrderIdentifierIds-object
Element | Type | Use | Definition | Mandatory |
Order(x) | object | Search criteria | OrderIdentifierId counter. For example: Inv1, Inv2, etc. | X |
2.2.1.1 Order(x)-object
Element | Type | Use | Definition | Mandatory |
OrderIdentifierId | int(11) | Search criteria | Identifier of the purchase order to be retrieved | X |
2.2.2 Filters-object
Element | Type | Use | Definition |
OrderNumbers | object | Search criteria | List of purchase order numbers to be retrieved |
StatusCodes | object | Search criteria | List of purchase order status codes to be retrieved |
DateRanges | object | Search criteria | List of date range filters for the purchase order to be retrieved |
2.2.2.1 OrderNumbers-object
Element | Type | Use | Definition | Mandatory |
OrderNumber | String | Search criteria | Purchase order number to be retrieved | X |
2.2.2.2 StatusCodes-object
Element | Type | Use | Definition | Mandatory |
StatusCode | Int | Search criteria | 1 = Incomplete 22 = Shelved 26 = Offer request 40 = Ordered 42 = Received 80 = Archived 90 = Cancelled | X |
PaymentStatusCode | 50 = Invoiced 52 = Paid |
2.2.2.3 DateRanges-object
Element | Type | Use | Definition | Mandatory |
DateRange | object | Search criteria | Date range filter Multiple elements perform an OR search | X |
2.2.2.3.1. DateRange-object
Element | Type | Use | Definition | Mandatory |
StartDate | date (YYYY-MM-DD) | Search criteria | Start date | X |
EndDate | date (YYYY-MM-DD) | Search criteria | End date | X |
SearchDate | string | Search criteria | The date to which the search applies. Possible options: OrderedDate = Order date ReceivedDate = Received date AgreedDeliveryDate = Agreed delivery date PrintedDate = Print date | X |
2.3 Response content (GET)
The content of the response returned by the service
Element | Type | Definition |
ResponseStatus | int (0/1) | 0=error 1=OK |
ResponseMessage | string | Additional description about events, errors, etc. |
NumberOfOrders | int | Number of orders found |
Orders | array | Found orders |
2.3.1. Orders-table
Element | Type | Definition |
OrderIdentifierId | int(11) | Identifier of a single purchase order |
OrderDate | date(YYYY-mm-dd) | Order date |
SellerPartyDetails | object | Seller details |
SellerContactPersonName | string | Contact person |
SellerCommunicationDetails | object | Contact details |
SellerInformationDetails | object | Purchase order information |
InvoiceRecipientPartyDetails | object | Payer details |
InvoiceRecipientContactPersonName | string | Contact person |
InvoiceRecipientCommunicationDetails | object | Contact details |
BuyerPartyDetails | object | Buyer details |
BuyerContactPersonName | string | Contact person |
BuyerCommunicationDetails | object | Contact details |
DeliveryPartyDetails | object | Delivery address details |
DeliveryContactPersonName | string | Contact person |
DeliveryCommunicationDetails | object | Contact details |
DeliveryDetails | object | Delivery details |
InvoiceDetails | object | Purchase order details |
PaymentStatusDetails | object | Purchase order status |
InvoiceRow | object | Purchase order rows |
2.3.1.1 SellerPartyDetails-object
Element | Type | Definition |
SellerPartyIdentifier | string | Business ID |
SellerOrganisationName | array(1-2) | Seller |
SellerOrganisationTaxCode | string | VAT number |
SellerPostalAddressDetails | object | Address details |
2.3.1.1.1 SellerOrganisationName-table
Element | Type | Definition |
OrganisationName | string | Seller name |
2.3.1.1.2 SellerPostalAddressDetails-object
Element | Type | Definition |
SellerStreetName | array(0...2) | Street addresses |
SellerTownName | string | Town / post office |
SellerPostCodeIdentifier | string | Postal code |
2.3.1.1.2.1 SellerStreetName-table
Element | Type | Definition |
StreetName | string | Street address |
2.3.1.2 SellerCommunicationDetails-object
Element | Type | Definition |
SellerPhoneNumberIdentifier | string | Phone number |
SellerEmailaddressIdentifier | string | E-mail address |
2.3.1.3 SellerInformationDetails-object
Element | Type | Definition |
SellerPhoneNumber | string | Phone number |
SellerCommonEmailaddressIdentifier | string | E-mail address |
2.3.1.4 InvoiceRecipientPartyDetails-object
Element | Type | Definition |
InvoiceRecipientPartyIdentifier | string | Business ID |
InvoiceRecipientOrganisationName | array(1-2) | Seller |
InvoiceRecipientOrganisationTaxCode | string | VAT number |
InvoiceRecipientPostalAddressDetails | object | Address details |
2.3.1.4.1 InvoiceRecipientOrganisationName-table
Element | Type | Definition |
OrganisationName | string | Invoice recipient name |
2.3.1.4.2 InvoiceRecipientPostalAddressDetails-object
Element | Type | Use |
InvoiceRecipientStreetName | array(0...2) | Street addresses |
InvoiceRecipientTownName | string | Town / post office |
InvoiceRecipientPostCodeIdentifier | string | Postal code |
23.1.4.2.1 InvoiceRecipientStreetName-table
Element | Type | Definition |
StreetName | string | Street address |
2.3.1.5 InvoiceRecipientCommunicationDetails-object
Element | Type | Definition |
InvoiceRecipientPhoneNumberIdentifier | string | Phone number |
InvoiceRecipientEmailaddressIdentifier | string | E-mail address |
2.3.1.6 BuyerPartyDetails-object
Element | Type | Definition |
BuyerPartyIdentifier | string | Business ID |
BuyerOrganisationName | array(1-2) | Seller |
BuyerOrganisationTaxCode | string | VAT number |
BuyerPostalAddressDetails | object | Address details |
2.3.1.7 BuyerOrganisationName-table
Element | Type | Definition |
OrganisationName | string | Buyer / customer name |
2.3.1.7.1 BuyerPostalAddressDetails-object
Element | Type | Definition |
BuyerStreetName | array(0...2) | Street addresses |
BuyerTownName | string | Town / post office |
BuyerPostCodeIdentifier | string | Postal code |
2.3.1.7.1.1 BuyerStreetName-table
Element | Type | Definition |
StreetName | string | Street address |
2.3.1.8 BuyerCommunicationDetails-object
Element | Type | Definition |
BuyerPhoneNumberIdentifier | string | Phone number |
BuyerEmailaddressIdentifier | string | E-mail address |
2.3.1.9 DeliveryPartyDetails-object
Element | Type | Definition |
DeliveryPartyIdentifier | string | Business ID |
DeliveryOrganisationName | array(1-2) | Seller |
DeliveryOrganisationTaxCode | string | VAT number |
DeliveryPostalAddressDetails | object | Address details |
2.3.1.9.1 DeliveryOrganisationName-table
Element | Type | Definition |
OrganisationName | string | Customer’s name |
2.3.1.9.2 DeliveryPostalAddressDetails-object
Element | Type | Definition |
DeliveryStreetName | array(0...2) | Street addresses |
DeliveryTownName | string | Town / post office |
DeliveryPostCodeIdentifier | string | Postal code |
2.3.1.9.2.1 DeliveryStreetName-table
Element | Type | Definition |
StreetName | string | Street address |
2.3.1.10 DeliveryCommunicationDetails-object
Element | Type | Definition |
DeliveryPhoneNumberIdentifier | string | Phone number |
DeliveryEmailaddressIdentifier | string | E-mail address |
2.3.1.11 DeliveryDetails-object
Element | Type | Definition |
DeliveryDate | date(YYYY-mm-dd) | Delivery date |
DeliveryMethodText | string | Delivery method |
DeliveryTermsText | string | Delivery terms |
DeliveryNoteIdentifier | string | Consignment note |
2.3.1.12 InvoiceDetails-object
Element | Type | Definition |
InvoiceNumber | string | Purchase order number |
SellerReferenceIdentifier | string | Seller’s reference |
OrderIdentifier | string | Orderer’s reference |
ProjectReferenceIdentifier | string | Project number |
InvoiceTotalVatExcludedAmount | double(####,##) | VAT free amount |
InvoiceTotalVatAmount | double(####,##) | VAT amount |
InvoiceTotalVatIncludedAmount | double(####,##) | Total amount including tax |
AmountCurrencyIdentifier | string(3) | Currency |
InvoiceFreeText | array | Invoice free text |
PaymentTermsDetails | object | Payment terms |
SalesOrders | array | Sales orders
|
2.3.1.12.1 InvoiceFreeText-table
Element | Type | Definition |
InvoiceFreeTextTitle | string | Free text title |
InvoiceFreeText | string |
2.3.1.12.2 PaymentTermsDetails-object
Element | Type | Definition |
PaymentTermsFreeText | string | Payment terms |
InvoiceDueDate | date(YYYY-mm-dd) | Agreed delivery date |
2.3.1.12.3 PaymentStatusDetails-object
Element | Type | Definition |
PaymentStatusCode | string | Purchase order status |
2.3.1.13 InvoiceRow-table
Element | Type | Definition |
RowIdentifier | string | Row identifier |
ArticleIdentifier | string | Product number |
ArticleName | string | Product name |
ArticleStockName | string | Stock name |
ArticleRackName | string | Shelf |
EanCode | string | EAN barcode |
SerialNumberIdentifier | string | Serial number |
ArticleInfoUrlText | array | Product extra info |
OrderedQuantity | double(####) | Ordered quantity |
DeliveredQuantity | double(####) | Delivered quantity |
QuantityUnitCode | string | Unit |
UnitPriceAmount | double(####,#####) | VAT free unit price |
UnitPurchaseAPriceAmount | double(####,#####) | VAT free unit a-price |
UnitPurchaseBPriceAmount | double(####,#####) | VAT free unit b-purchase price |
RowProjectReferenceIdentifier | string | Project number |
RowNormalProposedAccountIdentifier | string | Account |
RowAccountDimensionText | string | Cost center |
RowDiscountPercent | double(####) | Discount percentage |
RowVatRatePercent | double(####) | VAT percentage |
RowVatAmount | double(####,##) | VAT amount |
RowVatExcludedAmount | double(####,##) | Total amount excluding tax |
RowAmount | double(####,##) | Total amount including tax |
AmountCurrencyIdentifier | string(3) | Currency |
RowType | string | Row type |
RowInvoice | string(1) | Row invoicing
|
2.3.1.14 ArticleInfoUrlText-table
Element | Type | Definition |
ArticleInfoUrlText | string | Product extra info |
2.4 Request content (PUT)
Element | Type | Use | Default | Definition | Mandatory |
FinvoiceMethod | boolean | Control message | TRUE | Use TRUE | X |
Finvoices | object | Purchase orders | X | ||
CreateFromRowProjectReferenceIdentifier | boolean | Control message | FALSE | TRUE = create a new work number automatically if not found in the register. | |
CreateFromRowAccountDimensionText | boolean | Control message | FALSE | TRUE = a new cost center is created automatically if not found in the register. |
2.4.1 Finvoices-object
It is possible to import more than one Finvoice file in a single call via the WS purchase order.
Example of a request:
The content of the File field [BASE64] refers to a Finvoice file encoded in Base64.
<Finvoices>
<Finvoice1>
<FileName>Order_1.xml</FileName>
<File>[BASE64]</File>
</Finvoice1>
<Finvoice2>
<FileName>Order_2.xml</FileName>
<File>[BASE64]</File>
</Finvoice2>
<Finvoice3>
<FileName>Order_3.xml</FileName>
<File>[BASE64]</File>
</Finvoice3>
</Finvoices>
Finvoices-object
Element | Type | Definition | Mandatory |
Finvoice(x) | object | Purchase orders
| X |
2.4.1.1 Finvoice(x)-object
Element | Type | Definition | Mandatory |
FileName | string | File name | X |
File | text (base64) | File content | X |
2.4.1.2 NetBaron® Extensions to the Finvoice Standard
Element | Type | Definition |
SellerPartyDetails/ SellerCommunicationDetails/ SellerGsmNumberIdentifier | string | Buyer’s mobile phone number |
DeliveryPartyDetails / DeliveryCommunicationDetails / DeliveryGsmNumberIdentifier | string | Supplier’s mobile phone number |
InvoiceRecipientPartyDetails/ InvoiceRecipientCommunicationDetails/ InvoiceRecipientGsmNumberIdentifier | string | Invoice recipient's mobile phone number |
ExtraField1 – ExtraField6 | string | Extra fields 1–6 in the Additional information tab |
InternalInformationFreeText | string | Internal info in the Other data tab |
InvoiceInstructionFreeText | string | Billing instructions in the Instructions tab |
DeliveryInstructionFreeText | string | Delivery instructions in the Instructions tab |
TransportInstructionFreeText | string | Transport instructions in the Instructions tab |
InvoiceDetails/SalesOrders | array | Sales orders to which a link will be added from the purchase order being created. Contains 0 to n SalesOrderIdentifierId elements. For a detailed description, see section 2.4.1.3. |
InvoiceDetails/SalesOrders/SalesOrderIdentifierId | int | Sales order ID to which a link will be created from the purchase order being created. For a detailed description, see section 2.4.1.3. |
2.4.1.3 Linking sales orders to purchase orders being created
In the imported Finvoice, the SalesOrders element is located within the InvoiceDetails element.
There can be 0 to n SalesOrderIdentifierId elements.
<InvoiceDetails>
<SalesOrders>
<SalesOrderIdentifierId>227677</SalesOrderIdentifierId>
<SalesOrderIdentifierId>2201</SalesOrderIdentifierId>
</SalesOrders>
</InvoiceDetails>
When creating a purchase order, the interface checks that each SalesOrderIdentifierId corresponds to an existing sales order in the database.
If a matching sales order is not found, the interface returns an error message:
"One or more InvoiceDetails/SalesOrders/SalesOrderIdentifierIds doesn't exist in database", and the purchase order will not be created.
Incorrectly created links cannot be removed afterward.
2.5 Response content (PUT) -table
The content of the response returned by the service
Element | Type | Definition |
ResponseStatus | int (0/1) | 0=error 1=OK |
ResponseMessage | string | Additional description about events, errors, etc. |
OrderIdentifierId | object | Identifiers of the added purchase orders |
2.5.1 OrderIdentifierId-object
Element | Type | Definition |
[FileName] | object | Identifiers contained in the file |
2.5.1.1 [FileName]-object
Element | Type | Definition |
Status | int (0/1) | 0=error 1=OK |
Message | string | Additional description about events, errors, etc. |
OrderIdentifierId | string | Order identifier |
3. Code samples
It should be noted that the code samples presented in the documents are examples of how the interface can be used. Implementation of the codes requires PHP knowledge from the www-service provider. NetBaron Solutions Oy is not responsible for any direct or indirect damage and costs related to the sample codes when a third party does the implementation and further development.
Please note: The code created by your software developer must not cause server overload situations. We reserve the right to bill the creator of the software code or the end customer for system failure in the server environment. If necessary, please get the software code checked by sending it to tuki@netbaron.fi and adding the mention: "WS-Purchase Order interface software code to product development for review and possible feedback".
3.1 PHP (GET)
3.1.1. OrderIdentifierIds
<?php
function getresp($responsex, $pref=""){
$responserows = "";
foreach($responsex as $k => $r){
if(is_array($r)){
$responserows .= $pref."$k => Array(<br>".getresp($r,$pref." ").$pref."),<br>";
} else if(is_object($r)){
$responserows .= $pref."$k => Object(<br>".getresp($r,$pref." ").$pref."),<br>";
} else $responserows .= $pref."$k => $r<br>";
}
return $responserows;
}
$ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
$token = new stdClass;
// Depending on the client side, utf_encode might be required
$token->Username = new SOAPVar("username", XSD_STRING, null, null, null, $ns);
$token->Password = new SOAPVar("password", XSD_STRING, null, null, null, $ns);
$wsec = new stdClass;
$wsec->UsernameToken = new SoapVar($token, SOAP_ENC_OBJECT, null, null, null, $ns);
$soapHeaders[] = new SOAPHeader($ns, 'Security', $wsec->UsernameToken, true);
/**
* Client
*/
$client = new SoapClient(null, array(
"location" => "https://<serverurl>/ws/purchaseorder",
"uri" => "urn:NBWS",
'style' => SOAP_RPC,
'use' => SOAP_LITERAL,
"soap_version" => SOAP_1_2,
"compression" => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5,
"trace" => 1)
);
/**
* Set headers
*/
$client->__setSoapHeaders( $soapHeaders );
/**
* Call PHP soap
*/
try{
$Request = new stdClass();
$Request->GetSellerPartyDetails = true;
$Request->GetInvoiceRecipientPartyDetails = true;
$Request->GetBuyerPartyDetails = true;
$Request->GetDeliveryPartyDetails = true;
$Request->GetDeliveryDetails = true;
$Request->GetInvoiceDetails = true;
$Request->GetInvoiceFreeText = true;
$Request->GetInvoiceRow = true;
$Request->OrderIdentifierIds = new stdClass();
$Inv = "Inv2";
$Request->OrderIdentifierIds->$Inv = (object) array("OrderIdentifierId"=>"3800");
$response = $client->get( new SoapVar($Request, SOAP_ENC_OBJECT,"","","Request") );
if(is_object($response)){
$responserows = getresp($response);
} else $responserows = $response;
$response = "<b>RESPONSE</b><pre>".utf8_decode($responserows)."</b></pre>";
}
catch(SoapFault $fault){
$response .= "<b>SOAP Fault:</b><pre>faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring}</pre>";
}
echo $response;
?>
3.1.2 GetOrders
<?php
function getresp($responsex, $pref=""){
$responserows = "";
foreach($responsex as $k => $r){
if(is_array($r)){
$responserows .= $pref."$k => Array(<br>".getresp($r,$pref." ").$pref."),<br>";
} else if(is_object($r)){
$responserows .= $pref."$k => Object(<br>".getresp($r,$pref." ").$pref."),<br>";
} else $responserows .= $pref."$k => $r<br>";
}
return $responserows;
}
$ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
$token = new stdClass;
// Depending on the client side, utf_encode might be required
$token->Username = new SOAPVar("username", XSD_STRING, null, null, null, $ns);
$token->Password = new SOAPVar("password", XSD_STRING, null, null, null, $ns);
$wsec = new stdClass;
$wsec->UsernameToken = new SoapVar($token, SOAP_ENC_OBJECT, null, null, null, $ns);
$soapHeaders[] = new SOAPHeader($ns, 'Security', $wsec->UsernameToken, true);
/**
* Client
*/
$client = new SoapClient(null, array(
"location" => "https://<serverurl>/ws/purchaseorder",
"uri" => "urn:NBWS",
'style' => SOAP_RPC,
'use' => SOAP_LITERAL,
"soap_version" => SOAP_1_2,
"compression" => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5,
"trace" => 1)
);
/**
* Set headers
*/
$client->__setSoapHeaders( $soapHeaders );
/**
* Call PHP soap
*/
try{
$Request = new stdClass();
$Request->GetSellerPartyDetails = true;
$Request->GetInvoiceRecipientPartyDetails = true;
$Request->GetBuyerPartyDetails = true;
$Request->GetDeliveryPartyDetails = true;
$Request->GetDeliveryDetails = true;
$Request->GetInvoiceDetails = true;
$Request->GetInvoiceFreeText = true;
$Request->GetInvoiceRow = true;
$Request->GetInvoices = true;
$Request->GetOrders = true;
$Request->Filters = new stdClass;
$Request->Filters->OrderNumbers = new SoapVar(array(
new SoapVar('40141', XSD_STRING, null, null, 'OrderNumber'),
), SOAP_ENC_OBJECT);
$Request->Filters->StatusCodes = new SoapVar(array(
new SoapVar(1, XSD_INT, null, null, 'StatusCode'),
), SOAP_ENC_OBJECT);
$Request->Filters->DateRanges = new SoapVar(array(
new SoapVar(array(
'StartDate' => '2018-01-01',
'EndDate' => '2018-12-31',
'SearchDate' => 'OrderedDate'
), SOAP_ENC_OBJECT, null, null, 'DateRange'),
), SOAP_ENC_OBJECT);
$response = $client->get( new SoapVar($Request, SOAP_ENC_OBJECT,"","","Request") );
if(is_object($response)){
$responserows = getresp($response);
} else $responserows = $response;
$response = "<b>RESPONSE</b><pre>".utf8_decode($responserows)."</b></pre>";
}
catch(SoapFault $fault){
$response .= "<b>SOAP Fault:</b><pre>faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring}</pre>";
}
echo $response;
?>
3.2 PHP (PUT)
<?php
function getresp($responsex, $pref=""){
$responserows = "";
foreach($responsex as $k => $r){
if(is_array($r)){
$responserows .= $pref."$k => Array(<br>".getresp($r,$pref." ").$pref."),<br>";
} else if(is_object($r)){
$responserows .= $pref."$k => Object(<br>".getresp($r,$pref." ").$pref."),<br>";
} else $responserows .= $pref."$k => $r<br>";
}
return $responserows;
}
$ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
$token = new stdClass;
// Depending on the client side, utf_encode might be required
$token->Username = new SOAPVar("username", XSD_STRING, null, null, null, $ns);
$token->Password = new SOAPVar("password", XSD_STRING, null, null, null, $ns);
$wsec = new stdClass;
$wsec->UsernameToken = new SoapVar($token, SOAP_ENC_OBJECT, null, null, null, $ns);
$soapHeaders[] = new SOAPHeader($ns, 'Security', $wsec->UsernameToken, true);
/**
* Client
*/
$client = new SoapClient(null, array(
"location" => "https://<serverurl>/ws/purchaseorder",
"uri" => "urn:NBWS",
'style' => SOAP_RPC,
'use' => SOAP_LITERAL,
"soap_version" => SOAP_1_2,
"compression" => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5,
"trace" => 1)
);
/**
* Set headers
*/
$client->__setSoapHeaders( $soapHeaders );
/**
* Call PHP soap
*/
try{
$Request = new stdClass();
$Request->FinvoiceMethod = true;
$Request->InvoiceBill = true;
$Files = new stdClass();
$Files->Finvoice1 = new stdClass();
$Files->Finvoice1->FileName = utf8_encode("e-invoice.xml");
$Files->Finvoice1->File = new SoapVar(file_get_contents("e-invoice.xml"), XSD_BASE64BINARY);
$Request->Finvoices = $Files;
$response = $client->put( new SoapVar($Request, SOAP_ENC_OBJECT,"","","Request") );
if(is_object($response)){
$responserows = getresp($response);
} else $responserows = $response;
$response = "<b>RESPONSE</b><pre>".utf8_decode($responserows)."</b></pre>";
}
catch(SoapFault $fault){
$response .= "<b>SOAP Fault:</b><pre>faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring}</pre>";
}
echo $response;
?>
3.3 XML (GET)
3.3.1 OrderIdentifierIds
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urn:NBWS" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<env:Header>
<wsse:Security env:mustUnderstand="true">
<wsse:UsernameToken>
<wsse:Username>username</wsse:Username>
<wsse:Password>password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</env:Header>
<env:Body>
<env:Body>
<ns1:get>
<Request>
<GetSellerPartyDetails>true</GetSellerPartyDetails>
<GetInvoiceRecipientPartyDetails>true</GetInvoiceRecipientPartyDetails>
<GetBuyerPartyDetails>true</GetBuyerPartyDetails>
<GetDeliveryPartyDetails>true</GetDeliveryPartyDetails>
<GetDeliveryDetails>true</GetDeliveryDetails>
<GetInvoiceDetails>true</GetInvoiceDetails>
<GetInvoiceFreeText>true</GetInvoiceFreeText>
<GetInvoiceRow>true</GetInvoiceRow>
<OrderIdentifierIds>
<Order1>
<OrderIdentifierId>3800</OrderIdentifierId>
</Order1>
</OrderIdentifierIds>
</Request>
</ns1:get>
</env:Body>
</env:Envelope>
3.3.2 GetOrders
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urn:NBWS" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<env:Header>
<wsse:Security>
<wsse:UsernameToken>
<wsse:Username>username</wsse:Username>
<wsse:Password>password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</env:Header>
<env:Body>
<ns1:get>
<Request>
<GetSellerPartyDetails>true</GetSellerPartyDetails>
<GetInvoiceRecipientPartyDetails>true</GetInvoiceRecipientPartyDetails>
<GetBuyerPartyDetails>true</GetBuyerPartyDetails>
<GetDeliveryPartyDetails>true</GetDeliveryPartyDetails>
<GetDeliveryDetails>true</GetDeliveryDetails>
<GetInvoiceDetails>true</GetInvoiceDetails>
<GetInvoiceFreeText>true</GetInvoiceFreeText>
<GetInvoiceRow>true</GetInvoiceRow>
<GetOrders>true</GetOrders>
<Filters>
<OrderNumbers>
<OrderNumber>40141</OrderNumber>
</OrderNumbers>
<StatusCodes>
<StatusCode>1</StatusCode>
</StatusCodes>
<DateRanges>
<DateRange>
<StartDate>2018-01-01</StartDate>
<EndDate>2018-12-31</EndDate>
<SearchDate>OrderedDate</SearchDate>
</DateRange>
</DateRanges>
</Filters>
</Request>
</ns1:get>
</env:Body>
</env:Envelope>
3.4 Response (GET)
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urn:NBWS" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://www.w3.org/2003/05/soap-encoding" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<env:Body xmlns:rpc="http://www.w3.org/2003/05/soap-rpc">
<ns1:getResponse env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<rpc:result>Response</rpc:result>
<Response xsi:type="enc:Struct">
<ResponseStatus xsi:type="xsd:int">1</ResponseStatus>
<ResponseMessage xsi:type="xsd:string">
</ResponseMessage>
<NumberOfOrders xsi:type="xsd:int">1</NumberOfOrders>
<Orders xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:int">1</key>
<value xsi:type="enc:Struct">
<OrderIdentifierId xsi:type="xsd:string">3800</OrderIdentifierId>
<OrderDate xsi:type="xsd:string">2010-09-22</OrderDate>
<SellerPartyDetails xsi:type="enc:Struct">
<SellerPartyIdentifier xsi:type="xsd:string">1234567-1</SellerPartyIdentifier>
<SellerOrganisationName enc:itemType="enc:Struct" enc:arraySize="1" xsi:type="enc:Array">
<item xsi:type="enc:Struct">
<SellerOrganisationName xsi:type="xsd:string">Seller</SellerOrganisationName>
</item>
</SellerOrganisationName>
<SellerOrganisationTaxCode xsi:type="xsd:string">FI12345671</SellerOrganisationTaxCode>
<SellerPostalAddressDetails xsi:type="enc:Struct">
<SellerStreetName enc:itemType="enc:Struct" enc:arraySize="1" xsi:type="enc:Array">
<item xsi:type="enc:Struct">
<SellerStreetName xsi:type="xsd:string">Street</SellerStreetName>
</item>
</SellerStreetName>
<SellerTownName xsi:type="xsd:string">Town</SellerTownName>
<SellerPostCodeIdentifier xsi:type="xsd:string">00000</SellerPostCodeIdentifier>
</SellerPostalAddressDetails>
</SellerPartyDetails>
<SellerContactPersonName xsi:type="xsd:string">Contact</SellerContactPersonName>
<SellerCommunicationDetails xsi:type="enc:Struct">
<SellerPhoneNumberIdentifier xsi:type="xsd:string">123456789/SellerPhoneNumberIdentifier>
<SellerEmailaddressIdentifier xsi:type="xsd:string">email@email.fi</SellerEmailaddressIdentifier>
</SellerCommunicationDetails>
<SellerInformationDetails xsi:type="enc:Struct">
<SellerPhoneNumber xsi:type="xsd:string">123456789</SellerPhoneNumber>
<SellerCommonEmailaddressIdentifier xsi:type="xsd:string">email@email.fi</SellerCommonEmailaddressIdentifier>
</SellerInformationDetails>
<InvoiceRecipientPartyDetails xsi:type="enc:Struct">
<InvoiceRecipientPartyIdentifier xsi:type="xsd:string">1234567-8</InvoiceRecipientPartyIdentifier>
<InvoiceRecipientOrganisationName enc:itemType="enc:Struct" enc:arraySize="2" xsi:type="enc:Array">
<item xsi:type="enc:Struct">
<InvoiceRecipientOrganisationName xsi:type="xsd:string">Invoice recipient</InvoiceRecipientOrganisationName>
</item>
<item xsi:type="enc:Struct">
<InvoiceRecipientOrganisationName xsi:type="xsd:string">Invoice recipient2</InvoiceRecipientOrganisationName>
</item>
</InvoiceRecipientOrganisationName>
<InvoiceRecipientOrganisationTaxCode xsi:type="xsd:string">1234567-8</InvoiceRecipientOrganisationTaxCode>
<InvoiceRecipientPostalAddressDetails xsi:type="enc:Struct">
<InvoiceRecipientStreetName enc:itemType="enc:Struct" enc:arraySize="1" xsi:type="enc:Array">
<item xsi:type="enc:Struct">
<InvoiceRecipientStreetName xsi:type="xsd:string">Street</InvoiceRecipientStreetName>
</item>
</InvoiceRecipientStreetName>
<InvoiceRecipientTownName xsi:type="xsd:string">Town</InvoiceRecipientTownName>
<InvoiceRecipientPostCodeIdentifier xsi:type="xsd:string">00000</InvoiceRecipientPostCodeIdentifier>
</InvoiceRecipientPostalAddressDetails>
</InvoiceRecipientPartyDetails>
<InvoiceRecipientContactPersonName xsi:type="xsd:string">Contact</InvoiceRecipientContactPersonName>
<InvoiceRecipientCommunicationDetails xsi:type="enc:Struct">
<InvoiceRecipientPhoneNumberIdentifier xsi:type="xsd:string">123456789</InvoiceRecipientPhoneNumberIdentifier>
<InvoiceRecipientEmailaddressIdentifier xsi:type="xsd:string">email@email.fi</InvoiceRecipientEmailaddressIdentifier>
</InvoiceRecipientCommunicationDetails>
<BuyerPartyDetails xsi:type="enc:Struct">
<BuyerOrganisationName enc:itemType="enc:Struct" enc:arraySize="2" xsi:type="enc:Array">
<item xsi:type="enc:Struct">
<BuyerOrganisationName xsi:type="xsd:string">Buyer</BuyerOrganisationName>
</item>
<item xsi:type="enc:Struct">
<BuyerOrganisationName xsi:type="xsd:string">Buyer2</BuyerOrganisationName>
</item>
</BuyerOrganisationName>
<BuyerPostalAddressDetails xsi:type="enc:Struct">
<BuyerStreetName enc:itemType="enc:Struct" enc:arraySize="2" xsi:type="enc:Array">
<item xsi:type="enc:Struct">
<BuyerStreetName xsi:type="xsd:string">StreetBuyerStreetName>
</item>
<item xsi:type="enc:Struct">
<BuyerStreetName xsi:type="xsd:string">Street2</BuyerStreetName>
</item>
</BuyerStreetName>
<BuyerTownName xsi:type="xsd:string">Town</BuyerTownName>
<BuyerPostCodeIdentifier xsi:type="xsd:string">00000</BuyerPostCodeIdentifier>
</BuyerPostalAddressDetails>
</BuyerPartyDetails>
<BuyerContactPersonName xsi:type="xsd:string">Contact</BuyerContactPersonName>
<BuyerCommunicationDetails xsi:type="enc:Struct">
<BuyerPhoneNumberIdentifier xsi:type="xsd:string">123456789</BuyerPhoneNumberIdentifier>
<BuyerEmailaddressIdentifier xsi:type="xsd:string">email@email.fi</BuyerEmailaddressIdentifier>
</BuyerCommunicationDetails>
<DeliveryPartyDetails xsi:type="enc:Struct">
<DeliveryOrganisationName enc:itemType="enc:Struct" enc:arraySize="2" xsi:type="enc:Array">
<item xsi:type="enc:Struct">
<DeliveryOrganisationName xsi:type="xsd:string">Delivery</DeliveryOrganisationName>
</item>
<item xsi:type="enc:Struct">
<DeliveryOrganisationName xsi:type="xsd:string">Delivery2</DeliveryOrganisationName>
</item>
</DeliveryOrganisationName>
<DeliveryPostalAddressDetails xsi:type="enc:Struct">
<DeliveryStreetName enc:itemType="enc:Struct" enc:arraySize="1" xsi:type="enc:Array">
<item xsi:type="enc:Struct">
<DeliveryStreetName xsi:type="xsd:string">Street</DeliveryStreetName>
</item>
</DeliveryStreetName>
<DeliveryTownName xsi:type="xsd:string">Town</DeliveryTownName>
<DeliveryPostCodeIdentifier xsi:type="xsd:string">00000</DeliveryPostCodeIdentifier>
</DeliveryPostalAddressDetails>
</DeliveryPartyDetails>
<DeliveryContactPersonName xsi:type="xsd:string">Contact</DeliveryContactPersonName>
<DeliveryCommunicationDetails xsi:type="enc:Struct">
<DeliveryPhoneNumberIdentifier xsi:type="xsd:string">123456789</DeliveryPhoneNumberIdentifier>
<DeliveryEmailaddressIdentifier xsi:type="xsd:string">email@email.fi</DeliveryEmailaddressIdentifier>
</DeliveryCommunicationDetails>
<DeliveryDetails xsi:type="enc:Struct">
<DeliveryDate xsi:type="xsd:string">2010-09-29</DeliveryDate>
<DeliveryMethodText xsi:type="xsd:string">Posti, Tuotteiden hinta yli170e</DeliveryMethodText>
<DeliveryTermsText xsi:type="xsd:string">Vapaasti varastossa</DeliveryTermsText>
<DeliveryNoteIdentifier xsi:type="xsd:string">FI124356458967234</DeliveryNoteIdentifier>
</DeliveryDetails>
<InvoiceDetails xsi:type="enc:Struct">
<InvoiceNumber xsi:type="xsd:string">2010120</InvoiceNumber>
<SellerReferenceIdentifier xsi:type="xsd:string">Order number: 22010248</SellerReferenceIdentifier>
<OrderIdentifier xsi:type="xsd:string">OrderIdentifier</OrderIdentifier>
<ProjectReferenceIdentifier xsi:type="xsd:string">333333</ProjectReferenceIdentifier>
<InvoiceTotalVatExcludedAmount xsi:type="xsd:string">1071,31</InvoiceTotalVatExcludedAmount>
<InvoiceTotalVatAmount xsi:type="xsd:string">98,56</InvoiceTotalVatAmount>
<InvoiceTotalVatIncludedAmount xsi:type="xsd:string">1169,87</InvoiceTotalVatIncludedAmount>
<AmountCurrencyIdentifier xsi:type="xsd:string">EUR</AmountCurrencyIdentifier>
<InvoiceFreeText enc:itemType="enc:Struct" enc:arraySize="8" xsi:type="enc:Array">
<item xsi:type="enc:Struct">
<InvoiceFreeText xsi:type="xsd:string">From time: 1.9.2010-20.9.2010</InvoiceFreeText>
</item>
<item xsi:type="enc:Struct">
<InvoiceFreeText xsi:type="xsd:string">Type of bill: lasku</InvoiceFreeText>
</item>
</InvoiceFreeText>
<PaymentTermsDetails xsi:type="enc:Struct">
<PaymentTermsFreeText xsi:type="xsd:string">14 pv netto</PaymentTermsFreeText>
<InvoiceDueDate xsi:type="xsd:string">2010-10-13</InvoiceDueDate>
</PaymentTermsDetails>
</InvoiceDetails>
<PaymentStatusDetails xsi:type="enc:Struct">
<PaymentStatusCode xsi:type="xsd:string">Delivered</PaymentStatusCode>
</PaymentStatusDetails>
<InvoiceRow enc:itemType="enc:Struct" enc:arraySize="4" xsi:type="enc:Array">
<item xsi:type="enc:Struct">
<RowIdentifier xsi:type="xsd:string">9720</RowIdentifier>
<ArticleIdentifier xsi:type="xsd:string">ArticleIdentifier</ArticleIdentifier>
<ArticleGroupIdentifier xsi:type="xsd:string">ArticleGroupIdentifier</ArticleGroupIdentifier>
<ArticleName xsi:type="xsd:string">ArticleName</ArticleName>
<ArticleInfoUrlText enc:itemType="enc:Struct" enc:arraySize="1" xsi:type="enc:Array">
<item xsi:type="enc:Struct">
<ArticleInfoUrlText xsi:type="xsd:string">http://address.fi</ArticleInfoUrlText>
</item>
</ArticleInfoUrlText>
<EanCode xsi:type="xsd:string">4902030181000</EanCode>
<OrderedQuantity xsi:type="xsd:string">1</OrderedQuantity>
<DeliveredQuantity xsi:type="xsd:string">1</DeliveredQuantity>
<QuantityUnitCode xsi:type="xsd:string">kpl</QuantityUnitCode>
<UnitPriceAmount xsi:type="xsd:string">1000,00000</UnitPriceAmount>
<UnitPurchaseAPriceAmount xsi:type="xsd:string">900.605</UnitPurchaseAPriceAmount>
<UnitPurchaseBPriceAmount xsi:type="xsd:string">900.605</UnitPurchaseBPriceAmount>
<RowProjectReferenceIdentifier xsi:type="xsd:string">333333</RowProjectReferenceIdentifier>
<RowVatRatePercent xsi:type="xsd:string">9</RowVatRatePercent>
<RowVatAmount xsi:type="xsd:string">90,00</RowVatAmount>
<RowVatExcludedAmount xsi:type="xsd:string">1000,00</RowVatExcludedAmount>
<RowAmount xsi:type="xsd:string">1090,00</RowAmount>
<AmountCurrencyIdentifier xsi:type="xsd:string">EUR</AmountCurrencyIdentifier>
<RowType xsi:type="xsd:string">Material</RowType>
<RowInvoice xsi:type="xsd:string">Y</RowInvoice>
</item>
<item xsi:type="enc:Struct">
<RowIdentifier xsi:type="xsd:string">10048</RowIdentifier>
<ArticleIdentifier xsi:type="xsd:string">ArticleIdentifier</ArticleIdentifier>
<ArticleGroupIdentifier xsi:type="xsd:string">ArticleGroupIdentifier</ArticleGroupIdentifier>
<ArticleName xsi:type="xsd:string">ArticleName</ArticleName>
<SerialNumberIdentifier xsi:type="xsd:string">SerialNumberIdentifier</SerialNumberIdentifier>
<OrderedQuantity xsi:type="xsd:string">1</OrderedQuantity>
<DeliveredQuantity xsi:type="xsd:string">1</DeliveredQuantity>
<QuantityUnitCode xsi:type="xsd:string">kpl</QuantityUnitCode>
<UnitPriceAmount xsi:type="xsd:string">71,31000</UnitPriceAmount>
<UnitPurchaseAPriceAmount xsi:type="xsd:string">47.605</UnitPurchaseAPriceAmount>
<UnitPurchaseBPriceAmount xsi:type="xsd:string">47.605</UnitPurchaseBPriceAmount>
<RowProjectReferenceIdentifier xsi:type="xsd:string">333333</RowProjectReferenceIdentifier>
<RowNormalProposedAccountIdentifier xsi:type="xsd:string">1111</RowNormalProposedAccountIdentifier>
<RowAccountDimensionText xsi:type="xsd:string">22222</RowAccountDimensionText>
<RowVatRatePercent xsi:type="xsd:string">12</RowVatRatePercent>
<RowVatAmount xsi:type="xsd:string">8,56</RowVatAmount>
<RowVatExcludedAmount xsi:type="xsd:string">71,31</RowVatExcludedAmount>
<RowAmount xsi:type="xsd:string">79,87</RowAmount>
<AmountCurrencyIdentifier xsi:type="xsd:string">EUR</AmountCurrencyIdentifier>
<RowType xsi:type="xsd:string">Material</RowType>
<RowInvoice xsi:type="xsd:string">Y</RowInvoice>
</item>
</InvoiceRow>
</value>
</item>
</Orders>
</Response>
</ns1:getResponse>
</env:Body>
</env:Envelope>
3.5 XML (PUT)
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urn:NBWS" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<env:Header>
<wsse:Security env:mustUnderstand="true">
<wsse:UsernameToken>
<wsse:Username>username</wsse:Username>
<wsse:Password>password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</env:Header>
<env:Body>
<ns1:put>
<Request>
<FinvoiceMethod>true</FinvoiceMethod>
<Finvoices>
<Finvoice1>
<FileName>e-invoice</FileName>
<File>PD94bWwgdmVyc2...</File>
</Finvoice1>
</Finvoices>
</Request>
</ns1:put>
</env:Body>
</env:Envelope>
3.6 Response (PUT)
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urn:NBWS" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://www.w3.org/2003/05/soap-encoding" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<env:Body xmlns:rpc="http://www.w3.org/2003/05/soap-rpc">
<ns1:postResponse env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<rpc:result>Response</rpc:result>
<Response xsi:type="enc:Struct">
<ResponseStatus xsi:type="xsd:int">1</ResponseStatus>
<ResponseMessage xsi:type="xsd:string">
</ResponseMessage>
<OrderIdentifierId xsi:type="enc:Struct">
<e-invoice.xml xsi:type="enc:Struct">
<Status xsi:type="xsd:int">1</Status>
<Message xsi:type="xsd:string">
</Message>
<OrderIdentifierId xsi:type="xsd:string">3864</OrderIdentifierId>
</e-invoice.xml>
</OrderIdentifierId>
</Response>
</ns1:postResponse>
</env:Body>
</env:Envelope>