PHP SOAP 插入数据 StructType wsdltophp

PHP SOAP insert data StructType wsdltophp

我在一个必须调用 SOAP WS 的项目中工作。我使用了 WSDLtoPHP,这真的很有帮助。

我可以读取数据,现在我想使用网络服务创建新项目。但是当我试图在字段 Nom 中插入数据时,出现错误,因为 soap 服务器认为我正在尝试将我的数据($nom)插入到生成的 xml 字段 Nom 的属性 NomVide 中结构与我的代码:

<ven1:Nom NomVide="$nom"></ven1:Nom> 

    $createClient = $SC->S001_Creation_Client(new \StructType\S001_Creation_Client(
        new \StructType\RootWSReturnError(
            new \StructType\Header("","","","","",array(),"","","","","","","","","","","",array(),"",0,0,"",array(),array(),"","","","","","","","","","","","","","","","","","","","",0,0,"","",array(),"","","","",0,0,0,0,0,0,0),null),
        new \StructType\RootWSVenteParametres (array( new \StructType\Vente (array("secret_key")))),
        new \StructType\RootWSVenteClient(
            array(new \StructType\Client(
                    new \StructType\General(
                        "3333",
                        array(),
                        array(),
                        null,
                        new \StructType\Nom ($nom),
                        new \StructType\NomRecherche ($nomrecherche),
                        new \StructType\Nom2 ($nom2),
                        new \StructType\Marque1($marque1),
                        new \StructType\Marque2 ($marque2),
                        new \StructType\Adresse1 (),
                        new \StructType\Adresse2 (),
                        new \StructType\CodePostal(),
                        new \StructType\Ville (),
                        new \StructType\County (),
                        new \StructType\CountryRegion (),
                        new \StructType\CurrencyCode ($currencyCode),
                        new \StructType\CreditLimit ($creditLimit),
                        new \StructType\Blocked ($blocked),
                        new \StructType\PaymentMethodCode ($paymentMethodCode),
                        new \StructType\CustDiscGroup ($custDiscGroup),
                        new \StructType\SalespersonCode ($salespersonCode),
                        new \StructType\EquipeAgentCode ($equipeAgentCode),
                        new \StructType\LocationCode($locationCode),[...]

SOAP 服务器的日志给了我,然后我正在尝试这样做:

<ven1:Nom NomVide="$nom"></ven1:Nom>

当然是假的...

但我需要:

<ven1:Nom NomVide="">$nom</ven1:Nom>

这是我的 StructType\Nom class 代码:

    class Nom extends AbstractStructBase
    {
        /**
         * The NomVide
         * Meta information extracted from the WSDL
         * - use: optional
         * @var string|null
         */
        protected ?string $NomVide = null;
        /**
         * Constructor method for Nom
         * @uses Nom::setNomVide()
         * @param string $nomVide
         */
        public function __construct(?string $nomVide = null)
        {
            $this
                ->setNomVide($nomVide);
        }
        /**
         * Get NomVide value
         * @return string|null
         */
        public function getNomVide(): ?string
        {
            return $this->NomVide;
        }
        /**
         * Set NomVide value
         * @param string $nomVide
         * @return \StructType\Nom
         */
        public function setNomVide(?string $nomVide = null): self
        {
            // validation for constraint: string
            if (!is_null($nomVide) && !is_string($nomVide)) {
                throw new InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($nomVide, true), gettype($nomVide)), __LINE__);
            }
            $this->NomVide = $nomVide;
            
            return $this;
        }
    }

根据示例,值“3333”没有问题,它只是一个简单的字符串类型。 我对所有 StructType 类型都有这个问题。

如果有人知道如何帮助我

我终于找到了解决方案。

在 WSDL 源代码中,有多个同名节点,而在我的代码中,只有一个 class 是使用 WSDLtoPHP 按名称生成的。

我们要求 WSDL 所有者更改 WSDL 中的节点名称,我们使用 WSDLtoPHP 库生成了新的 class。

现在开始工作了!