Forum Moderators: coopster

Message Too Old, No Replies

issues generating soap

ms gp great plains wsdl organization key not generating proper xml

         

phazei

8:38 pm on Mar 13, 2010 (gmt 0)

10+ Year Member



I'm working with MS Dynamics GP server SOAP/WSDL integration with a php cart.

I'm using php5.2.13's soapClient

I have to have an organization key, which is of type company key, that needs an id of 1. Otherwise I get a soap fault.
This is how it should look:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/dynamics/gp/2006/01" xmlns:ns2="http://schemas.microsoft.com/dynamics/2006/01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:GetCustomerByKey>
<ns1:key>
<ns1:Id>UCTest001</ns1:Id>
</ns1:key>
<ns2:Context>
<ns2:OrganizationKey xsi:type="ns2:CompanyKey">
<ns2:Id>1</ns2:Id>
</ns2:OrganizationKey>
<ns2:CurrencyType>Transactional</ns2:CurrencyType>
</ns2:Context>
</ns1:GetCustomerByKey>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


But with this code:

$newCust = new stdClass();
$newCust->key->Id = $custKey;
$newCompanyKey = new stdClass();
$newCompanyKey->Id = 1;
$newCust->Context->OrganizationKey = $newCompanyKey;
$newCust->Context->CurrencyType = CurrencyType::Transactional;
$GetCustomerByKey = $newCust;

It looks like this

<ns2:OrganizationKey/>

and gives the error:
"The specified type is abstract: name='OrganizationKey'"

If I exclude OrganizationKey entirely it gives this error:
"The application encountered an unhandled system exception. Contact your system administrator for details."

It ignores the type and the id in OrganizationKey when I send it. I'm doing that with stdClass as I thought that was supposed to work.

I found this thread:
[mail-archive.com...]
But it just says it's not needed.

This is from the WSDL:

<s:complexType name="OrganizationKey" abstract="true">
<s:complexContent mixed="false">
<s:extension base="s2:Key" />
</s:complexContent>
</s:complexType>
<s:complexType name="Key" abstract="true" />
<s:complexType name="CompanyKey">
<s:complexContent mixed="false">
<s:extension base="s2:OrganizationKey">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="Id" type="s:int" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>


This is the example:
[msdn.microsoft.com...]
and
[msdn.microsoft.com...]


OTOH, if I create specific classes for everything and do this:

$Context = new Context();
$Context->OrganizationKey = new CompanyKey();
$Context->OrganizationKey->Id = '1'; //1 real, 2 ?
$Context->CurrencyType = CurrencyType::Transactional;

AND map those classes with $options['classmap'] then it does work.

So why does it work one way, not the other, and how can I make stdClass work in a way where it won't skip the Id.

Thanks

coopster

8:07 pm on Apr 23, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



So why does it work one way, not the other


I think you already answered your own question ...

"The specified type is abstract: name='OrganizationKey'"


Something in your SOAP function must be kicking this error, I would assume. But the code example here doesn't show that. I would track that error back to the line number and start from there.