laravel-soap 使用

甄坚白
2023-12-01
<?php
namespace App\Http\Controllers;


use SoapWrapper;


class ApiController extends Controller
{


    public function demo()
    {
        SoapWrapper::add(function ($service) {
            $service
                ->name('currency')
                ->wsdl('http://127.0.0.1/terminal/trunk/api/soapwsdl.wsdl')
                ->header('http://127.0.0.1/terminal/trunk/soap/','Authentication',["username"=>"admin","pass"=>"admin"], false, SOAP_ACTOR_NEXT)
                ->trace(true);
        });




        $string = '<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:cwmp="urn:dslforum-org:cwmp-1-0">
					  		<SOAP-ENV:Header>
						<cwmp:ID SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" SOAP-ENV:mustUnderstand="1">1</cwmp:ID>
					  </SOAP-ENV:Header>
					  <SOAP-ENV:Body>
						<cwmp:Inform>
						<DeviceId xsi:type="DeviceldStruct">
							<Manufacturer xsi:type="xsd:string">CYLIX</Manufacturer>
							<OUI xsi:type="xsd:string">wmid</OUI>
							<ProductClass xsi:type="xsd:string">CY-DZ1380</ProductClass>
							<SerialNumber xsi:type="xsd:string">004201FF004188501442FCD5D901450H</SerialNumber>
						</DeviceId>
						<Event SOAP-ENC:arrayType="cwmp:EventStruct[1]">
							<EventStruct>
								<EventCode xsi:type="xsd:string">1 BOOT</EventCode>
								<CommandKey xsi:type="xsd:string"></CommandKey>
							</EventStruct>
						</Event>
						<MaxEnvelopes xsi:type="xsd:unsignedInt">1</MaxEnvelopes>
						<CurrentTime xsi:type="xsd:dateTime">2014-12-01T09:21:01+08:00</CurrentTime>
						<RetryCount xsi:type="xsd:unsignedInt">0</RetryCount>
						<ParameterList SOAP-ENC:arrayType="cwmp:ParameterValueStruct[22]">
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.DeviceInfo.HardwareVersion</Name>
								<Value xsi:type="xsd:string">CY-DZ1380_1.0</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.DeviceInfo.SoftwareVersion</Name>
								<Value xsi:type="xsd:string">53.1.6</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.DeviceInfo.AdditionalHardwareVersion</Name>
								<Value xsi:type="xsd:string"></Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.DeviceInfo.AdditionalSoftwareVersion</Name>
								<Value xsi:type="xsd:string"></Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.ManagementServer.ConnectionRequestURL</Name>
								<Value xsi:type="xsd:string">http://192.168.1.109:7547</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.ManagementServer.ConnectionRequestUsername</Name>
								<Value xsi:type="xsd:string">admin</Value></ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.ManagementServer.ConnectionRequestPassword</Name>
								<Value xsi:type="xsd:string">admin</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.DeviceInfo.ModelName</Name>
								<Value xsi:type="xsd:string">CY-DZ1380</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.DeviceInfo.Description</Name>
								<Value xsi:type="xsd:string">SDMC STB</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.DeviceInfo.FirstUseDate</Name>
								<Value xsi:type="xsd:string">2014-12-01 09:20:59</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.DeviceInfo.UpTime</Name>
								<Value xsi:type="xsd:int">09:20:58</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.Time.NTPServer1</Name>
								<Value xsi:type="xsd:string"></Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.LAN.DNSServers</Name>
								<Value xsi:type="xsd:string">202.96.134.133</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.LAN.AddressingType</Name>
								<Value xsi:type="xsd:string">DHCP</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.LAN.IPAddress</Name>
								<Value xsi:type="xsd:string">192.168.1.109</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.LAN.MACAddress</Name>
								<Value xsi:type="xsd:string">FC:D5:D9:01:7F:89</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.X_CMCC_OTV.STBInfo.STBID</Name>
								<Value xsi:type="xsd:string">004201FF004188501442FCD5D901450H</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.X_CMCC_OTV.ServiceInfo.UserID</Name>
								<Value xsi:type="xsd:string">user</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.X_CMCC_OTV.ServiceInfo.PPPoEID</Name>
								<Value xsi:type="xsd:string"></Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.X_CMCC_OTV.ServiceInfo.AuthURL</Name>
								<Value xsi:type="xsd:string">http://www.baidu.com</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.DeviceType</Name>
								<Value xsi:type="xsd:string">STB</Value>
							</ParameterValueStruct>
							<ParameterValueStruct>
								<Name xsi:type="xsd:string">Device.DeviceSummary</Name>
								<Value xsi:type="xsd:string">This is a  Mbox</Value>
							</ParameterValueStruct>
						</ParameterList>
						</cwmp:Inform>
					  </SOAP-ENV:Body>
					</SOAP-ENV:Envelope>';




        SoapWrapper::service('currency', function ($service) use ($string) {
            $s = $service->call('inform',['dd'=>$string]);
            print_r($s);exit;
//            $clean_xml = str_replace(['SOAP-ENV:', 'SOAP:','cwmp:'], '', $s);
//            $com = (array)simplexml_load_string($clean_xml);
//            print_r((array)$com['Body']->Inform->ParameterList);
//            foreach((array)$com['Body']->Inform->ParameterList as $k=>$v){
//                print_r($v);
//            }


        });
    }












}

 类似资料: