如何在PHP中将参数正确传递给Soap Web服务

时间:2018-10-24 19:58:36

标签: php soap wsdl

我有此请求XML:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://pqjsalud/">
  <SOAP-ENV:Body>
    <ns1:generaCitas>
      <arg0>
        <apeMaterno>AGUILAR</apeMaterno>
        <apePaterno>SALDAÑA</apePaterno>
        <aseguradora>40006</aseguradora>
        <nombre>MONICA VANESSA</nombre>
      </arg0>
    </ns1:generaCitas>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

使用在线肥皂客户端,我通常会收到响应:

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope
    xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:generaCitasResponse
            xmlns:ns2="http://pqjsalud/">
            <return>45|85</return>
        </ns2:generaCitasResponse>
    </S:Body>
</S:Envelope>

使用PHP代码,我试图通过以下代码使用此Web服务:

$client = new SoapClient('HERE-IS-MY-WS-WSDL-URL');

if ($client) {
    $soapParams = array(
        'apeMaterno'    => 'AGUILAR',
        'apePaterno'    => 'SALDAÑA',
        'aseguradora'   => 40006,
        'nombre'        => 'MONICA VANESSA',
    );

    $result = $client->__soapCall('generaCitas', $soapParams);

    var_dump($result);
}

但是我收到了“ java.lang.NullPointerException”,我在做什么错了?

谢谢!

0 个答案:

没有答案