如何定义一个SoapVar命名空间? [英] How to define a SoapVar namespace?

查看:85
本文介绍了如何定义一个SoapVar命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的SOAP请求(使用1.1)中包含此节点:

I need to have this node in my SOAP Request (using 1.1):

<CredentialsHeader xmlns="http://www.url.com/Services/P24ListingService11"
    <EMail>ricky@email.net</EMail>
    <Password>password</Password>
</CredentialsHeader>

所以我有以下PHP:

$client = new SoapClient("https://exdev.www.example.com/Services/example.asmx?WSDL", 
    array(
        "trace"      => 1,
        "exceptions" => 0,
        "cache_wsdl" => 0,
        'soap_version' => SOAP_1_1
        )
);

$CredentialObject = new SoapVar(array('EMail' => 'ricky@email.net', 'Password' => 'password'), SOAP_ENC_OBJECT);

哪个生成:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.example.com/Services/Example">
    <SOAP-ENV:Header>
        <ns1:CredentialsHeader>
            <EMail>ricky@email.net</EMail>
            <Password>password</Password>
        </ns1:CredentialsHeader>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:EchoAuthenticated/>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

我要做的就是使用ns1阻止它,并像这样在节点中实际定义xmlns:

All I need to do is prevent it using ns1 and actually define the xmlns in the node like so:

<CredentialsHeader xmlns="http://www.example.com/Services/Example">
        <EMail>ricky@email.net</EMail>
        <Password>password</Password>
    </CredentialsHeader>

我已经在Firefox Poster中对其进行了测试,并且知道更改可以解决问题的事实.

I have tested that in Firefox Poster and know for a fact that change fixes the problem.

推荐答案

$CredentialObjectXML  = '<CredentialsHeader xmlns="http://www.example.com/Services/Example">
        <EMail>'.$UserName.'</EMail>
        <Password>'.$Password.'</Password>
    </CredentialsHeader>';


$CredentialObject  = new SoapVar($CredentialObjectXML,XSD_ANYXML);

这样,您可以直接将XML与XSD_ANYXML类型一起使用.

This way you can directly use the XML with Type XSD_ANYXML.

希望这可以解决您的问题.

Hope this will resolve your problem.

这篇关于如何定义一个SoapVar命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆