标签: soapserver

在PHP中处理SOAP标头

我正在构建(在PHP中)一个SOAP服务器,该服务器由其WSDL配置为接受如下所示的消息:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://my.awesome.namespace/">
    <SOAP-ENV:Header>
        <ns1:Header>
            <ns1:APIKey>E4C5BDE0-48DC-543C-1CA3-8E55C63F8E60</ns1:APIKey>
            <ns1:SiteID>111</ns1:SiteID>
        </ns1:Header>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:Heartbeat>
            <ns1:Message>Hello world.</ns1:Message>
        </ns1:Heartbeat>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)

我没有问题让我的SOAPServer处理Heartbeat消息 - $server->addFunction("Heartbeat");工作正常.但是,我希望能够处理<ns1:Header>机箱的内容- 因此我可以验证API密钥和站点ID,以确保它们应该是什么.

我看了这里,(当然还有其他地方),但响应者似乎错过了问题的重点.有谁知道我如何访问标题元素来验证?我是否可以像在身体中使用方法一样为Header添加函数?($server->addFunction("Header");?)

首先十分感谢.

php soap soapserver

3
推荐指数
1
解决办法
3869
查看次数

如何填充复合消息并作为SoapServer响应XML返回?

我正在设置一个SOAP Web服务,它应该返回一个复合消息.
此消息的有效实例如下:

<dl190Response xmlns="http://pse/">
    <cdhead cisprik="5563167"/>
    <mvts>
        <mvts_S att="a1">
            <x>x1</x>
            <w>w1</w>
        </mvts_S>
        <mvts_S>
            <x>x2</x>
            <w>w2</w>
        </mvts_S>
    </mvts>
</dl190Response>
Run Code Online (Sandbox Code Playgroud)

所有这些都在wsdl中得到了很好的定义:

<?xml version="1.0" encoding="UTF-8"?>
<definitions
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="http://pse/"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    name="PSE"
    targetNamespace="http://pse/">
    <types>
        <xs:schema xmlns="http://pse/" targetNamespace="http://pse/">
            <xs:complexType name="cdhead_T">
                <xs:attribute name="cisprik" type="xs:long"/>
            </xs:complexType>
            <xs:complexType name="mvts_T">
                <xs:sequence>
                    <xs:element name="mvts_S" type="mvts_S_T" minOccurs="0" maxOccurs="unbounded"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="mvts_S_T">
                <xs:sequence>
                    <xs:element name="x" type="xs:string"/>
                    <xs:element name="w" type="xs:string"/>
                </xs:sequence>
                <xs:attribute name="att" type="xs:string" use="optional"/>
            </xs:complexType>
        </xs:schema>
    </types>
    <message name="DL190Req">
        <part name="cdhead" type="tns:cdhead_T"/>
    </message>
    <message name="DL190Res">
        <part name="cdhead" type="tns:cdhead_T"/>
        <part name="mvts" …
Run Code Online (Sandbox Code Playgroud)

php xml soap web-services soapserver

3
推荐指数
1
解决办法
3694
查看次数

SoapServer发送没有信封的响应

我想发送一个纯xml肥皂响应,即没有肥皂信封.这是我目前的回应

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
   <SOAP-ENV:Body>
      <ns1:getMemberResponse>
         <User>
            <ValidationErrors/>
            <IsDeleted>false</IsDeleted>
            <ID>1691</ID>......
Run Code Online (Sandbox Code Playgroud)

但是,这是我想发送的回复

<User xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ValidationErrors />
  <IsDeleted>false</IsDeleted>
  <ID>1691</ID>.....
Run Code Online (Sandbox Code Playgroud)

有没有人有什么建议?

提前谢谢了

php xml soap soapserver

2
推荐指数
1
解决办法
1552
查看次数

symfony2的肥皂网服务

我需要使用symfony2创建一个web服务我已经阅读了官方文章http://symfony.com/doc/current/cookbook/web_services/php_soap_extension.html ,在示例中它使用参数路由.wsdl文件创建了一个SoapServer 实例,这是什么文件?我没有在symfony中找到太多关于soap的文档.请帮帮忙吗?

public function indexAction()
{
    $server = new \SoapServer('/path/to/hello.wsdl');
    $server->setObject($this->get('hello_service'));

    $response = new Response();
    $response->headers->set('Content-Type', 'text/xml; charset=ISO-8859-1');

    ob_start();
    $server->handle();
    $response->setContent(ob_get_clean());

    return $response;
}
Run Code Online (Sandbox Code Playgroud)

soap web-services soapserver symfony

1
推荐指数
1
解决办法
6157
查看次数

WSSE Security PHP SoapServer- Header not understood

I have a client call with a WSSE Security Header:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-7BCCD9337425FBA038149772606059420"><wsse:Username>USERNAME</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">NONCE</wsse:Nonce><wsu:Created>2017-06-17T19:01:00.594Z</wsu:Created></wsse:UsernameToken></wsse:Security></soapenv:Header>
   <soapenv:Body>
      <ns:FUNCTION/>
   </soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)

As SoapServer I have a simple one:

// the SOAP Server options
$options=array(
    'trace' => true
    , 'cache_wsdl' => 0
    , 'soap_version' => SOAP_1_1
    , 'encoding' => 'UTF-8'
);

$wsdl = 'http://localhost/index.php?wsdl';

$server = new \SoapServer($wsdl, $options);
$server->setClass('ServerClass');
$server->handle();
$response = ob_get_clean();
echo $response;
Run Code Online (Sandbox Code Playgroud)

As soon the property MustUnderstand = 1, then I become from the server the …

php soap-client soapserver

1
推荐指数
1
解决办法
1311
查看次数

php soapserver返回更好的可读关联数组

我正在使用PHP SOAPSERVER类.

作为响应,我发送关联的php数组:

function getItems()    
{    
   ...
   $items[] = Array("itemID" =>$itemID,"itemName"=>$itemName);
   return $items;
 }
Run Code Online (Sandbox Code Playgroud)

SOAP返回是这样的:

...
<Items>
<item type="Map">
    <item>
        <key type="string">
            itemID
        </key>
        <value type="string">
            17558
        </value>
    </item>
    <item>
        <key type="string">
            itemName
        </key>
        <value type="string">
            I-17558
        </value>
    </item>
</item>
</Items>
...
Run Code Online (Sandbox Code Playgroud)

这种回归很难分析人类(给定更大的数组).首选形式如下:

    ...
<Items>
    <item>
        <itemID>17558</itemID>
        <itemName>I-17558</itemName>
    </item>
    <item>
        <itemID>17559</itemID>
        <itemName>I-17559</itemName>
    </item>
</Items>
    ...
Run Code Online (Sandbox Code Playgroud)

这样的SOAP返回是否可行(不改变返回类型 - 数组)?怎么样?

我刚刚开始使用SOAP,大多数教程都展示了如何返回像string这样的简单类型.

php soap soapserver

0
推荐指数
1
解决办法
1102
查看次数

标签 统计

soapserver ×6

php ×5

soap ×5

web-services ×2

xml ×2

soap-client ×1

symfony ×1