i have to get some data using SOAP api from one org to another .so i generated Enterprise wsdl file of one organization . it contains some fields with specified type as type=xsd:anyType. because apex doesn't support xsd:anyType thats why i changed it to xsd:string .ok it will generate some apex classes .i want to know is it the proper way.for handling anyType or we should do some thing else .Please guideline
The Enterprise and Partner APIs are intended for usage outside of Salesforce rather than integrating two Salesforce Orgs together. They are typically consumed by languages like Java, .NET, PHP, Ruby, ...
As you found, anyType is not supported by Wsdl2Apex. See Supported WSDL Features:
The Salesforce datatype anyType is not supported in WSDLs used to generate Apex code that is saved using API version 15.0 and later. For code saved using API version 14.0 and earlier, anyType is mapped to String.
So in earlier versions anyType was mapped to string. You can certainly change it in the WSDL element types to get WSDL2Apex to import it.
It appears to only be used on the NewValue and OldValue elements on History Types. E.g. from AccountHistory.
<element name="NewValue" nillable="true" minOccurs="0" type="xsd:anyType"/> <element name="OldValue" nillable="true" minOccurs="0" type="xsd:anyType"/>
If you aren't going to be working with these History sObjects then you aren't likely to have any issues with the change.
- You can alter the Partner WSDL to call it from Apex. See Calling Salesforce Web Services Using Apex. It still defines anyType, but is isn't used directly in the WSDL. You will need to handle the meta data more, but this will also make your solution less susceptible to schema changes in the target org.
- You could use Salesforce to Salesforce to share data between the two orgs.