Q:

wsdl issue in soap api call

My first post,pretty excited.I want to make a soap api call which insert multiple records. I am using 2 different salesforce instances.
destination side
global with sharing class SoapDemo1
{
   global class AccountWrapper
   {
      webservice string Name;
      AccountWrapper(Account a)
      {
        this.Name=a.Name;
      }
   }

   webservice static List<Account> CreateMultipleAccounts(List<Account> accs)
   {
       List<Account> FinalList=new List<Account>();

       for(Account a:accs)
       {
          Account a1=new Account();
          a1.Name=a.Name;

          FinalList.add(a1);   
       }

       if (FinalList.size() > 0)
       {
          Database.Insert(FinalList);
       }

       return FinalList;
    }   
 }

I generated the class wsdl file and also partner wsdl file
****source side:****
I upload the class wsdl file generated from destination, when I parse no errors, but when I click Generated Apex code, it shows error as:

Unable to find complexType for
  {http://soap.sforce.com/schemas/class/SoapDemo1}anyType 

I changed anyType to string and again repeated the process but it shows error as:

Unable to find complexType for
  {http://soap.sforce.com/schemas/class/SoapDemo1}JunctionIdListNames

Please help me out

A:

The simplest solution for the given code would be to simplify the the parameters for the webservice method and the return type.
If you switched to taking a List of strings that represent the Account names and returning a List of strings that are the Id's of the new Accounts then the WSDL would be greatly simplified.
Or if you needed something a bit more advanced create an inner wrapper class for usage as either the input parameters or return type. It looks like you are already part way there with your AccountWrapper class. You just need to actually use it in the method for the parameters, and potentially the return type as well.

The problem  you are encountering occurs when you include an sObject in the parameters. You end up generating complex types in the WSDL that have type="xsd:anyType". This doesn't have native support in wsdl2apex because the underlying WebserviceCallout.invoke() method doesn't know how to handle an arbitrary type.
If you really want to proceed with the web method unchanged you could try the version of Wsdl2Apex in the FuseIT SFDC Exploer (Disclosure: The is my current employer). The version we made there will automatically convert the anytype into a string. You probably won't be able to call anything that depends on it, but you likely won't need to either.

