phpweb-servicessoapsage-erp

Creating a client Sage X3 from Web Services using PHP SOAP


I'm using SOAP PHP to create a client Sage X3 but my request SOAP failed. Here is my code :

$xml='<PARAM>
  <GRP ID="BPC0_1" >
    <FLD NAME="BCGCOD" TYPE="Char" >CUS</FLD>
    <FLD MENULAB="Oui" MENULOCAL="1" NAME="BPCSTA" TYPE="Integer" >2</FLD>
    <FLD NAME="BPCNAM" TYPE="Char" >'.$shorte_name.'</FLD>
  </GRP>
  <GRP ID="BPRC_1" >
    <FLD NAME="CRY" TYPE="Char" >MA</FLD>
    <FLD NAME="LAN" TYPE="Char" >FRA</FLD>
    <FLD NAME="CRN" TYPE="Char" >tnrte</FLD>
    <FLD NAME="CUR" TYPE="Char" >MAD</FLD>
  </GRP>
  <TAB DIM="30" ID="BPAC_1" SIZE="1" >
    <LIN NUM="1" >
      <FLD NAME="CODADR" TYPE="Char" >addr</FLD>
      <FLD NAME="BPADES" TYPE="Char" >'.$ville.'</FLD>
      <FLD NAME="BPACRY" TYPE="Char" >MA</FLD>
      <FLD NAME="CRYNAM" TYPE="Char" >Maroc</FLD>
      <FLD NAME="ADDLIG1" TYPE="Char" >'.$adresse.'</FLD>
      <FLD NAME="ADDLIG2" TYPE="Char" ></FLD>
      <FLD NAME="ADDLIG3" TYPE="Char" ></FLD>
      <FLD NAME="POSCOD" TYPE="Char" >'.$code_postal.'</FLD>
      <FLD NAME="CTY" TYPE="Char" >'.$ville.'</FLD>
      <FLD NAME="SAT" TYPE="Char" ></FLD>
      <FLD NAME="TEL1" TYPE="Char" >'.$phone_fixe.'</FLD>
      <FLD NAME="WEB1" TYPE="Char" >'.$web_site.'</FLD>
      <FLD NAME="WEB3" TYPE="Char" ></FLD>
      <FLD MENULAB="Non" MENULOCAL="1" NAME="BPAADDFLG" TYPE="Integer" >1</FLD>
    </LIN>
  </TAB>
  <GRP ID="BPC3_1" >
    <FLD NAME="ZACCCOD" TYPE="Char" ></FLD>
  </GRP>
  <GRP ID="BPC3_2" >
    <FLD NAME="VACBPR" TYPE="Char" >AF</FLD>
  </GRP>
  <GRP ID="BPC3_3" >
    <FLD NAME="PTE" TYPE="Char" >CH30D60D_1020</FLD>
  </GRP>
</PARAM>';

$soapclient=new SoapClient($WSDL);
$callContext = array('codeLang'=>$CODE_LANG, 'codeUser'=>$CODE_USER, 'password'=>$PASSWORD, 'poolAlias'=>$POOL_ALIAS, 'requestConfig'=>$REQUEST_CONFIG);                         
$response = $soapclient->__soapCall('save', array($callContext, "YWSBPC", $xml),   array( 'uri' => 'http://www.adonix.com/WSS', 'soapaction' => ''));}

Unfortunately my request failed and it returned this error :

stdClass Object (
  [messages] => Array (
    [0] => stdClass Object (
      [message] => Niveau d'accés insuffisant
      [type] => 3
    )
  )
  [resultXml] => [status] => 0
  [technicalInfos] => stdClass Object (
    [busy] =>
    [changeLanguage] =>
    [changeUserId] =>
    [flushAdx] =>
    [loadWebsDuration] => 0.055482
    [nbDistributionCycle] => 1
    [poolDistribDuration] => 1.134829
    [poolEntryIdx] => 0
    [poolExecDuration] => 383.223727
    [poolRequestDuration] => 385.851035
    [poolWaitDuration] => 1.492052
    [processReport] =>
    [processReportSize] => 0
    [reloadWebs] => 
    [resumitAfterDBOpen] => 
    [rowInDistribStack] => 1 
    [totalDuration] => 391.547802 
    [traceRequest] => 
    [traceRequestSize] => 0
  )
) 

I'm sure the WSDL and context are correct because I use the same code to read a client and it works.

Also I tried to use SoapUI 5.2.1 - I used a valid XML request but I get the same error.


Solution

  • The error message is in French and means insufficient access level. This link explains it well.

    Boils down to checking the user rights of the user you are using to process the request. Also gives tips on changing your language for your web services.