Exemplo n.º 1
0
 public function testSerialization()
 {
     $transport = new SOAPDummyTransport();
     $client = new XPSoapClient('http://xp-framework.net/', 'urn://test');
     // Re-set transport as constructor created a copy of it!
     $client->setTransport($transport);
     $client->registerMapping(new \xml\QName('http://net.xp_framework/soap/types', 'SoapTestType'), \lang\XPClass::forName('webservices.unittest.soap.SoapMappingTestTarget'));
     try {
         $client->invoke('foo', new SoapMappingTestTarget('Teststring', 12345));
     } catch (\xml\XMLFormatException $ignored) {
         // We don't receive a "real" answer, which will cause an exception
     }
     $msg = $transport->getRequest();
     $body = $msg->_bodyElement();
     $this->assertEquals('http://net.xp_framework/soap/types', $body->nodeAt(0)->nodeAt(0)->getAttribute('xmlns:ns1'));
     $this->assertEquals('ns1:SoapTestType', $body->nodeAt(0)->nodeAt(0)->getAttribute('xsi:type'));
 }
Exemplo n.º 2
0
    public function testDeepArrayResult()
    {
        $transport = new SOAPDummyTransport();
        $transport->setAnswer('<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:si="http://soapinterop.org/xsd"
 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:ctl="ctl"
>
<SOAP-ENV:Body>  
  <ctl:irrelevant>
    <item>
      <scalar>some string</scalar>
      <array>
        <string>first value</string>
        <string>second value</string>
      </array>
    </item>
  </ctl:irrelevant>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
');
        $client = new XPSoapClient('http://xp-framework.net/', 'urn://test');
        $client->setTransport($transport);
        $this->assertEquals(['scalar' => 'some string', 'array' => ['string' => ['first value', 'second value']]], $client->invoke('irrelevant'));
    }