duanbishai5271 2017-03-14 20:44
浏览 41

如何在启用WSDL的SoapClient中处理抽象类型?

I need to handle external SOAP service with WSDL. Example of valid request (simplified) is:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <RunCommand xmlns="https://me.com/MyService">
            <request>
                <Credentials>
                    <User>jack</User>
                    <Password>abc123</Password>
                </Credentials>
                <Command xsi:type="SomeCommand">
                    <Foo>bar</Foo>
                </Command>
            </request>
        </RunCommand>
    </soap:Body>
</soap:Envelope>

The problem is that according to WSDL, Command element is of abstract CommandType type, so I need to specify xsi:type. I know how to do it with SoapVar, but it seems like if I use SoapVar, all WSDL-mode automation is gone.

For simple WSDLs, that would be enough:

$soapClient->RunCommand([
    'Request' => [
        'Credentials' => [
            'user' => 'jack',
            'password' => 'abc123',
        ],
        'Command' => [
            'Foo' => 'bar'
        ]
    ]   
]);

But in this case, I'm getting an exception:

The specified type is abstract: name='CommandType'

I know how to make Command element for SoapClient, but I'm not sure how to mix it all together. I tried this:

$soapClient->RunCommand([
    'Request' => [
        'Credentials' => [
            'user' => 'jack',
            'password' => 'abc123',
        ],
        new SoapVar(
            ['Foo' => 'bar'],
            SOAP_ENC_OBJECT,
            'CommandType',
            null,
            'Command'
        )
    ]   
]);

But it doesn't create a request I need. How can I form the request I need with SoapClient to keep as much WSDL goodies as possible?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 AT89C51控制8位八段数码管显示时钟。
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口