0

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?

Antwort

0

Ich habe einen Workaround und es funktioniert jetzt für mich.

änderte ich die $ request Variable in der Klasse NTLMSoapClient, weil die Seife Umschlag, der zu meinen Dienst absolut nutzlos war geschickt PHP.

Also im Grunde habe ich nur diese vor den curl Aktionen:

$request = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:new="urn:microsoft-dynamics-schemas/codeunit/MyService"> 
       <soapenv:Header/> 
       <soapenv:Body> 
        <new:FGetContact> 
        <new:iContactNumber>'.$this->iContactNumber.'</new:iContactNumber> 
        </new:FGetContact> 
       </soapenv:Body> 
      </soapenv:Envelope>'; 

(Wenn jemand das gleiche Problem haben, versuchen Sie var_dump ($ request) und Quelltext anzeigen in Browser Sie werden sehen, was ein PHP Chaos tat. da ...)

1

Für was es wert ist, hatte ich dieses Problem und löste es durch Hinzufügen von "cache_wsdl" => WSDL_CACHE_NONE zu den Optionen des Soap-Clients.

Einige Felder wegen einer Cache-Ausgabe fehlten nach der WSDL-Update.