Connect to Web Serice from Excel VBA - Parameter is null err

HenrikDKHenrikDK Member Posts: 14
Hi

I am trying to connect to a Web Service from VBA in Excel. It is working fine; I have connected to the Web Service and I have started the code execution in the Codeunit I connect to. Now I wish to add a parameter to the Web Service and it keeps giving me an error that the parameter "pdepartment" is Null!.

I have searched for hours how to solve this and have found a few things that could affect it:
- It is not possible to send parameters in XML to a NAV Web Services from Excel
- You have to be very careful with case (upper / lower) of the function and parameter - I have tried to change it to different things, but it had no effect

Anyone that have an idea what to try? I am getting more and more frustrated.

Thanks in advance.

Yours sincerely
Henrik

The Codeunit
file.php?mode=view&id=4909&sid=faca771beb9640e9538bae2fcb564696

The Web Service
file.php?mode=view&id=4912&sid=faca771beb9640e9538bae2fcb564696

The VBA Code
file.php?mode=view&id=4910&sid=faca771beb9640e9538bae2fcb564696

Which create this XML file:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
	<soap:Body>
		<Createjob>
			<pdepartment>h</pdepartment>
		</Createjob>
	</soap:Body>
</soap:Envelope>

The Error
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">a:Microsoft.Dynamics.Nav.Service.WebServices.ServiceBrokerException</faultcode><faultstring xml:lang="da-DK">Parameter pdepartment in method Createjob in service Job_Functions2 is null! </faultstring><detail><string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Parameter pdepartment in method Createjob in service Job_Functions2 is null! </string></detail></s:Fault></s:Body></s:Envelope>

Answers

  • HenrikDKHenrikDK Member Posts: 14
    I found a solution with the help of a friend.

    The solution was to add a Namespace in my Createjob part which ended with the name of my Codeunit Web Service, but with the rest being standard.
    XMLCallString = "<?xml version=""1.0"" encoding=""UTF-8""?>" & _
        "<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
            "<soap:Body>" & _
                "<Createjob xmlns=""urn:microsoft-dynamics-schemas/codeunit/Job_Functions"">" & _
                    "<pdepartment>2</pdepartment>" & _
                "</Createjob>" & _
            "</soap:Body>" & _
        "</soap:Envelope>"
    
Sign In or Register to comment.