Ich versuche, einen Ansprechpartner aus meinem Dynamics Nav Web Service (Dynamics Nav 2016) zu erhalten. Ich mache das mit einer SOAP-Anfrage in PHP.Dynamics NAV 2016 Web Service: Parameter * in Methode * in Service * ist null
Der Webservice ist eine Codeunit, die zwei Funktionen:
fGetContact(iContactNumber : Text[20]) oContact : Text[250]
IF rContact.GET(iContactNumber) THEN BEGIN
oContact := '';
oContact := rContact."No." + ';' +
rContact."Company Name" + ';' +
rContact."First Name" + ';' +
rContact.Surname + ';' +
rContact."E-Mail";
END;
EXIT(oContact);
fGetContacts() oContacts : Text[250]
IF rContact.GET('KT100190') THEN BEGIN
oContacts := '';
oContacts := rContact."No." + ';' +
rContact."Company Name" + ';' +
rContact."First Name" + ';' +
rContact.Surname + ';' +
rContact."E-Mail";
END;
EXIT(oContacts);
Die zweite Funktion, fGetContacts, funktioniert gut. Aber wenn ich fGetContact mit einer Kontaktnummer als Parameter aufrufen, gibt es den folgenden Fehler:
Parameter iContactNumber in method FGetContact in service MyService is null!
Ich verwende den NTLMSoapClient wie folgt aus:
<?php
ini_set('soap.wsdl_cache_enabled', '0');
require_once 'ntlmstream.php';
require_once 'ntlmsoapclient.php';
$url = 'http://localhost:7047/DynamicsNAV90/WS/CRONUS/Codeunit/MyService';
$options = array(
'uri' => $url,
'location' => $url,
'trace' => true,
'login' => 'my_user',
'password' => 'my_password'
);
// we unregister the current HTTP wrapper
stream_wrapper_unregister('http');
// we register the new HTTP wrapper
stream_wrapper_register('http', 'MyServiceProviderNTLMStream') or die("Failed to register protocol");
// so now all request to a http page will be done by MyServiceProviderNTLMStream.
// ok now, let's request the wsdl file
// if everything works fine, you should see the content of the wsdl file
$client = new MyServiceNTLMSoapClient(null, $options);
// should display your reply
try {
$params = array('iContactNumber' => 'KT100190');
echo '<pre>';
echo $client->FGetContacts(); // works
echo $client->FGetContact($params); // doesn't work
echo '</pre>';
} catch (SoapFault $e) {
echo '<pre>';
var_dump($e);
echo '</pre>';
}
// restore the original http protocole
stream_wrapper_restore('http');
Ich habe auch versucht die Funktion wie folgt aufrufen :
echo $client->FGetContact('KT100190');
Der Rückkehrfehler ist derselbe wie vorher.
testete ich meine Funktion mit SoapUI und der Rückgabewert ist genau das, was es sein shuold.
Anfrage:
Antwort:
<Soap:Envelope xmlns:Soap="http://schemas.xmlsoap.org/soap/envelope/">
<Soap:Body>
<FGetContact_Result xmlns="urn:microsoft-dynamics-schemas/codeunit/MyService">
<return_value>KT100190;Add-ON Marketing;Chris;McGurk;[email protected]</return_value>
</FGetContact_Result>
</Soap:Body>
</Soap:Envelope>
Also, was mache ich falsch, dass dieser Fehler angezeigt wird, und wie kann ich es beheben?