Search code examples
phpweb-servicessoapnavision

how can i use the function CREATE in soap webservice in Navision in PHP?


Here you can see documentation. It is in C# . I tried to make a working example using PHP. I managed to execute the Read & ReadMultiple functions in PHP. This is my try:

   require ("./NTLMSoapClient.php");
    $client = new NTLMSoapClient(null, array(
        'cache_wsdl' => WSDL_CACHE_NONE,
        'trace' => true,
        'location' => "http://83.166.204.26:7147/TEST/WS/Harmont%20Blaine_TEST/Page/WebItem",
        'uri' => "urn:microsoft-dynamics-schemas/page/webitem",

    ));
    $client->user = "xxxxxx";
    $client->password = "xxxxxxxxx";
 try{

    $resp = $client->Create(new SoapVar('555554', XSD_STRING, null, null, 'ns1:No' ));
    echo "REQUEST:\n" . htmlentities($client->__getLastRequest()) . "\n";
}catch(SoapFault $sf){
    //echo "REQUEST:\n" . htmlentities($client->__getLastRequest()) . "\n";
    print '<pre>';
    print_r($sf); 
    print '</pre>'; 
}
print '<pre>';var_dump($resp);  print '</pre>';

It returns me NULL for some reason. Any idea why is not working?


Solution

  • THIS is the solution :

    $resp = $client->Create(new SoapVar('5555195', XSD_STRING, null, null, 'ns1:WebItem' ));
    

    I have to change the No to WebItem

    see here:

    <xsd:element name="Create">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element minOccurs="1" maxOccurs="1" name="WebItem" type="tns:WebItem"/></xsd:sequence></xsd:complexType>
    </xsd:element>