NS_ENSURE_ARG_POINTER(aEncoding); NS_ENSURE_ARG_POINTER(&aNamespaceURI); NS_ENSURE_ARG_POINTER(&aName); NS_ENSURE_ARG_POINTER(aDestination); NS_ENSURE_ARG_POINTER(aReturnValue); *aReturnValue = nsnull;
    nsStructEncoder::Encode(nsISOAPEncoding * aEncoding,                             nsIVariant * aSource,                             const nsAString & aNamespaceURI,                             const nsAString & aName,                             nsISchemaType * aSchemaType,                             nsISOAPAttachments * aAttachments,                             nsIDOMElement * aDestination,                             nsIDOMElement * *aReturnValue){  nsIID* iid;  nsCOMPtr<nsISupports> ptr;  nsresult rc = aSource->GetAsInterface(&iid, getter_AddRefs(ptr));  if (NS_FAILED(rc))    return rc;  nsCOMPtr<nsIPropertyBag>pbptr = do_QueryInterface(ptr);  if (pbptr) {  //  Do any object that can QI to a property bag.    nsCOMPtr<nsISchemaModelGroup>modelGroup;    if (aSchemaType) {      nsCOMPtr<nsISchemaComplexType>ctype = do_QueryInterface(aSchemaType);      if (ctype) {        rc = ctype->GetModelGroup(getter_AddRefs(modelGroup));        if (NS_FAILED(rc))          return rc;      }    }    if (aName.IsEmpty()) {      rc = EncodeSimpleValue(aEncoding, kEmpty,                             nsSOAPUtils::kSOAPEncURI,                             kStructSOAPType, aSchemaType, aDestination,                             aReturnValue);    }    else {      rc = EncodeSimpleValue(aEncoding, kEmpty,                           aNamespaceURI, aName, aSchemaType, aDestination,                           aReturnValue);    }    if (NS_FAILED(rc))      return rc;    return EncodeStructParticle(aEncoding, pbptr, modelGroup, aAttachments, *aReturnValue);  }  return SOAP_EXCEPTION(NS_ERROR_ILLEGAL_VALUE,"SOAP_PROPERTYBAG_REQUIRED","When encoding as a struct, an object with properties is required");}