/** * Generate a Soap Header using the specified service URI and SoapAction * Include the details from the Security Token for login * * @ignore */ protected function generateSoapHeader($serviceURI, $soapAction, $securityToken) { $soapHeaderDOM = new DOMDocument(); $headerNode = $soapHeaderDOM->appendChild($soapHeaderDOM->createElement('s:Header')); $headerNode->appendChild($soapHeaderDOM->createElement('a:Action', $soapAction))->setAttribute('s:mustUnderstand', '1'); $headerNode->appendChild($soapHeaderDOM->createElement('SdkClientVersion', "8.1.0.383"))->setAttribute('xmlns', 'http://schemas.microsoft.com/xrm/2011/Contracts'); $headerNode->appendChild($soapHeaderDOM->createElement('UserType', "CrmUser"))->setAttribute('xmlns', 'http://schemas.microsoft.com/xrm/2011/Contracts'); $headerNode->appendChild($soapHeaderDOM->createElement('a:ReplyTo'))->appendChild($soapHeaderDOM->createElement('a:Address', 'http://www.w3.org/2005/08/addressing/anonymous')); $headerNode->appendChild($soapHeaderDOM->createElement('a:MessageId', 'urn:uuid:' . parent::getUuid())); $headerNode->appendChild($soapHeaderDOM->createElement('a:To', $serviceURI))->setAttribute('s:mustUnderstand', '1'); $securityHeaderNode = $this->authentication->getSecurityHeaderNode($securityToken); $headerNode->appendChild($soapHeaderDOM->importNode($securityHeaderNode, true)); return $headerNode; }
public function constructFromSimpleXMLElement(SimpleXMLElement $attribute) { $this->logicalName = strtolower((string) $attribute->LogicalName); $this->label = (string) $attribute->DisplayName->UserLocalizedLabel->Label; $this->description = (string) $attribute->Description->UserLocalizedLabel->Label; $this->format = (string) $attribute->Format; $this->maxLength = (int) $attribute->MaxLength; $this->imeMode = (string) $attribute->ImeMode; $this->isCustom = (string) $attribute->IsCustomAttribute === 'true'; $this->isPrimaryId = (string) $attribute->IsPrimaryId === 'true'; $this->isPrimaryName = (string) $attribute->IsPrimaryName === 'true'; $this->type = (string) $attribute->AttributeType; /* Determine the Type of the Attribute */ $attributeList = $attribute->attributes(); $attributeType = AbstractClient::stripNS((string) $attributeList['type']); /* Handle the special case of Lookup types */ $this->isLookup = $attributeType == 'LookupAttributeMetadata'; /* If it's a Lookup, check what Targets are allowed */ if ($this->isLookup) { $this->lookupTypes = array(); /* Add lookup types to Properties, search for target entities */ foreach ($attribute->Targets->string as $target) { array_push($this->lookupTypes, (string) $target); } } else { $this->lookupTypes = null; } $this->isValidForCreate = (string) $attribute->IsValidForCreate === 'true'; $this->isValidForUpdate = (string) $attribute->IsValidForUpdate === 'true'; $this->isValidForRead = (string) $attribute->IsValidForRead === 'true'; /* Check if this field is mandatory */ $this->requiredLevel = (string) $attribute->RequiredLevel->Value; $this->attributeOf = (string) $attribute->AttributeOf; $this->optionSet = (string) $attribute->OptionSet->Name; /* If this is an OptionSet, determine the OptionSet details */ if (!empty($attribute->OptionSet) && !empty($attribute->OptionSet->Name)) { $this->optionSet = new OptionSet($attribute->OptionSet); } else { /* Not an OptionSet */ $this->optionSet = null; } }