简体   繁体   English

我如何使用PHP进行SOAP xsi:type

[英]How I do SOAP xsi:type with PHP

I need to do following structure to SOAP call: 我需要对SOAP调用执行以下结构:

    <a>$a</a>
    <b>$b</b>
    <c>
    <d>
        <e>$e</e>
        <f>
            <g>$g</g>
            ...
        </f>
        <i>$i</i>
        <j>
            <k>$k</k>
            <l>$l</l>
            <foo type="bar">
                <asd>$asd</asd>
                ...
            </foo>
        </j>
    </d>
</c>

Tricky part is , without it I could just do multidimensional array and call $client->method($array_format); 棘手的是,没有它,我只能做多维数组,然后调用$ client-> method($ array_format); and everything else works, even when I just do 'bar' => array('id' => 'foo')b but with type I can't do that cause bar is subtype of foo. 并且其他所有东西都可以用,即使我只做'bar'=> array('id'=>'foo')b但用类型我也做不到,这是因为bar是foo的子类型。 I have tried to do that one part with SoapVar, but it doesn't work either. 我试图用SoapVar做到这一点,但它也不起作用。 Server still complains that request need to have foo, when I give foo, it says that it must have one of bar's as subtype. 服务器仍然抱怨请求需要有foo,当我给foo时,它说它必须具有bar的子类型之一。 I only have example of a full document what server side expects to get, and they normally get requests from Java/C clients where this isn't apparently a problem. 我只有服务器端希望获取的完整文档的示例,并且它们通常从Java / C客户端获取请求,而这显然不是问题。 How I can either send manually constructed document or get this working with array-format and use SoapClient -class? 如何发送手动构建的文档或如何使用数组格式并使用SoapClient -class?

Actually, you should at least use the native php SoapClient class. 实际上,您至少应该使用本机php SoapClient类。

But nowadays, WSDL to PHP generator really eases the work such as the PackageGenerator project. 但是如今,WSDL to PHP生成器确实简化了诸如PackageGenerator项目之类的工作。

Using the generated package, it will be as clear as crystal 使用生成的包,它将像水晶一样清晰

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM