SOAP isteği PHP5

1 Cevap php

Ben bir sabun isteği yapmak için çalışıyorum ve zorluklar yaşıyorum.

İşte benim php:

<?php
$option=array('trace'=>1);
$soapClient = new SoapClient('http://www.domain.com/ws/AccountManagement.wsdl', $option); 

$headers = array('LOGIN_ID' => 'user@user.com', 'LOGIN_PASSWORD' => 'mypassword'); 

$header = new SoapHeader('https://www.domain.com', 'AuthenticationDTO', $headers, false);  

$soapClient->__setSoapHeaders($header); //or array($header)

$params = array(
'bureauName' => '',
'businessInformation' => array('address' => array('city' => 'SomeCity'), array('country' => 'US'), array('state' => 'MN'), array('street' => 'Some Address'), array('zipCode' => '33212')), array('businessName' => 'SomeBusinessName'),
'entityType' => '',
'listOfSimilars' => 'true',
);


try { 
    $result = $soapClient->__call("matchCompany", $params);
    print_r($result);
} catch (SoapFault $fault) { 
   echo $fault->faultcode . "-" . $fault->faultstring; 
   echo "REQUEST:\n" . htmlentities($soapClient->__getLastRequest()) . "\n";
} 

>

Bu $ soapClient__call başarısız.

getLastRequest () Bu XML üretir:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://com.dnbi.eai.service.AccountSEI" xmlns:ns2="http://dto.eai.dnbi.com">
  <SOAP-ENV:Header>
    <ns2:AuthenticationDTO>
      <ns2:LOGIN_ID>user@user.com</ns2:LOGIN_ID>
      <ns2:LOGIN_PASSWORD>mypassword</ns2:LOGIN_PASSWORD>
    </ns2:AuthenticationDTO>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns1:matchCompany/>
    <param1><item>
      <key>address</key>
      <value><item>
        <key>city</key>
        <value>SomeCity</value>
        </item></value>
      </item><item>
      <key>0</key>
      <value><item>
        <key>country</key>
        <value>US</value>
        </item></value>
      </item><item>
      <key>1</key>
      <value><item>
        <key>state</key>
        <value>MN</value>
        </item></value>
      </item><item>
      <key>2</key>
      <value><item>
        <key>street</key>
        <value>Some Address</value>
        </item></value>
      </item><item>
      <key>3</key>
      <value><item>
        <key>zipCode</key>
        <value>33212</value>
        </item></value>
      </item></param1>
    <param2><item>
      <key>businessName</key>
      <value>SomeBusinessName</value>
      </item></param2>
    <param3></param3>
    <param4>true</param4>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Bu doğru XML çıkışı değildir. Ben yanlış bir şey yapıyor olması gerekir. SoapUI kullanarak bu doğru XML olduğunu bulundu:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dto="http://dto.eai.dnbi.com" xmlns:com="http://com.dnbi.eai.service.AccountSEI">
   <soapenv:Header>
      <dto:AuthenticationDTO>
         <dto:LOGIN_ID>user@user.com</dto:LOGIN_ID>
         <dto:LOGIN_PASSWORD>mypassword</dto:LOGIN_PASSWORD>
      </dto:AuthenticationDTO>
   </soapenv:Header>
   <soapenv:Body>
      <com:matchCompany>
         <com:in0>
            <!--Optional:-->
            <dto:bureauName></dto:bureauName>
            <!--Optional:-->
            <dto:businessInformation>
               <dto:address>
         <!--Optional:-->
                  <dto:city>SomeCity</dto:city>
                  <dto:country>US</dto:country>
                  <dto:state>MN</dto:state>
                  <dto:street>Some Address</dto:street>
                  <!--Optional:-->
                  <dto:zipCode></dto:zipCode>
               </dto:address>
               <!--Optional:-->
               <dto:businessName>SomeBusinessName</dto:businessName>
            </dto:businessInformation>
            <!--Optional:-->
            <dto:entityNumber></dto:entityNumber>
            <!--Optional:-->
            <dto:entityType></dto:entityType>
            <!--Optional:-->
            <dto:listOfSimilars>true</dto:listOfSimilars>
         </com:in0>
      </com:matchCompany>
   </soapenv:Body>
</soapenv:Envelope>

Biri bana soapUI benim için üretilen aynı XML üretmek, ancak PHP5 yerli Sabun istemcisi kullanarak yardımcı olabilir misiniz?

Teşekkürler

1 Cevap

Yerine bu kodu deneyin. Bu gerekli hiyerarşisi oluşturmak için anonim nesneler nasıl kullandığını Not:

$options = array(
    'trace' => 1
);

$soapClient = new SoapClient('http://www.domain.com/ws/AccountManagement.wsdl', $option);  

$headers = array(
    'LOGIN_ID' => 'user@user.com',
    'LOGIN_PASSWORD' => 'mypassword'
);  

$header = new SoapHeader('dto', 'AuthenticationDTO', $headers, false);   

$soapClient->__setSoapHeaders($header); 

$matchCompany->in0->bureauName = '';
$matchCompany->in0->businessInformation->address->city = 'SomeCity';
$matchCompany->in0->businessInformation->address->country = 'US';
$matchCompany->in0->businessInformation->address->state = 'MN';
$matchCompany->in0->businessInformation->address->street = 'Some Address';
$matchCompany->in0->businessInformation->address->zipCode = '33212';
$matchCompany->in0->businessInformation->businessName = 'SomeBusinessName';
$matchCompany->in0->entityType = '';
$matchCompany->in0->listOfSimilars = true;

try
{  
    $result = $soapClient->matchCompany($matchCompany);     
    print_r($result); 
}
catch(SoapFault $fault)
{  
   echo $fault->faultcode . "-" . $fault->faultstring;  
   echo "REQUEST:\n" . htmlentities($soapClient->__getLastRequest()) . "\n"; 
}