notfalsedev / laravel-soap

A soap client wrapper for Laravel
MIT License
634 stars 122 forks source link

How to pass XML payload #177

Closed tutorialdrive closed 4 years ago

tutorialdrive commented 4 years ago

We are trying to pass XML payload to Web Logic Server. System accepts only SOAP Request and we are trying to pass below payload. But I am not sure how should we generate and pass payload something similar to below.

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inf="http://127.0.0.1:7003/infranetwebsvc/services/Infranet">
   <soapenv:Header/>
   <soapenv:Body>
      <inf:opcode soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <opcode xsi:type="xsd:string">PCM_OP_CUST_COMMIT_CUSTOMER</opcode>
         <inputXML xsi:type="xsd:string"><![CDATA[<?xml version="1.0" encoding="UTF-8"?><PCM_OP_CUST_COMMIT_CUSTOMER_inputFlist>
<POID>0.0.0.1 /plan 87296</POID>
<LOCALES elem="0">
    <LOCALE>en_AU</LOCALE>
</LOCALES>
<CODE>Basic Plan</CODE>
<WRITE_ACCESS>S</WRITE_ACCESS>
<NAME>Basic Plan</NAME>
<READ_ACCESS>B</READ_ACCESS>
<FLAGS>0</FLAGS>
<MOD_T>1578998441</MOD_T>
<CREATED_T>1578998441</CREATED_T>
<DESCR>BRT Basic Plan</DESCR>
<PAYINFO elem="0">
    <INV_TYPE>257</INV_TYPE>
    <NAME>Invoice1</NAME>
    <POID>0.0.0.1 /payinfo/invoice -1</POID>
    <FLAGS>1</FLAGS>
    <PAY_TYPE>10001</PAY_TYPE>
</PAYINFO>

</PCM_OP_CUST_COMMIT_CUSTOMER_inputFlist>

         ]]></inputXML>
      </inf:opcode>
   </soapenv:Body>
</soapenv:Envelope>

Testing Connection is working file with below code, but getting type error if I try to use any other function. something related to this:https://github.com/artisaninweb/laravel-soap/issues/163 :

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Artisaninweb\SoapWrapper\SoapWrapper;
use App\Soap\Request\GetConversionAmount;
use App\Soap\Response\GetConversionAmountResponse;

class SoapController {

    /**
     * @var SoapWrapper
     */
    protected $soapWrapper;

    /**
     * SoapController constructor.
     *
     * @param SoapWrapper $soapWrapper
     */
    public function __construct(SoapWrapper $soapWrapper) {
        $this->soapWrapper = $soapWrapper;
    }

    /**
     * Use the SoapWrapper
     */
    public function test() {
        $this->soapWrapper->add('Customer', function ($service) {
            $service
                    ->wsdl('http://127.0.0.1:7003/infranetwebsvc/services/CustServices?wsdl')
                    ->trace(true)
                    ->options([
                        'user_agent' => 'PHPSoapClient', // Add this as options
                    ])
                    ->classmap([
                        GetConversionAmount::class,
                        GetConversionAmountResponse::class,
            ]);
        });

        // Without classmap
        $response = $this->soapWrapper->call('Customer.pcmOpCustCreateProfile');

        dd($response);
        exit;
    }

}