Generate/save JSON or XML file from JSON script

I have a JSON script which at first Search for jobs with a specific attribute and then afterwards Get the job details.

For now the script is like this and is saved as a Postman collection:

{
    info: {
        _postman_id: xxx,
        name: JOBAD Service,
        schema: https://schema.getpostman.com/json/collection/v2.1.0/collection.json
    },
    item: [
        {
            name: GetJob,
            request: {
                method: POST,
                header: [
                    {
                        key: SOAPAction,
                        value: http://xxx,
                        type: text
                    },
                    {
                        key: Content-Type,
                        value: text/xml,
                        type: text
                    }
                ],
                body: {
                    mode: raw,
                    raw: soapenv:Envelope xmlns:soapenv=\http://schemas.xmlsoap.org/soap/envelope/\ xmlns:job=\http://jobnet.af.dk/JobAdService\ xmlns:job1=\http://schemas.datacontract.org/2004/07/JobAdService.DataContract\\r\n   soapenv:Header\r\n      job:Credentials\r\n         job1:Passwordxxx/job1:Password\r\n         job1:Usernamexxx/job1:Username\r\n      /job:Credentials\r\n   /soapenv:Header\r\n   soapenv:Body\r\n      job:GetJobRequestType\r\n         !--Optional:--\r\n         job:JobAdId5490138/job:JobAdId\r\n      /job:GetJobRequestType\r\n   /soapenv:Body\r\n/soapenv:Envelope
                },
                url: {
                    raw: https://xxx.svc,
                    protocol: https,
                    host: [
                        xxx,
                        xxx,
                        dk
                    ],
                    path: [
                        JobAdService,
                        v3,
                        JobAdService.svc
                    ]
                }
            },
            response: []
        },
        {
            name: SearchJob,
            request: {
                method: POST,
                header: [
                    {
                        key: Content-Type,
                        value: text/xml,
                        type: text
                    },
                    {
                        key: SOAPAction,
                        value: http:xxx,
                        type: text
                    }
                ],
                body: {
                    mode: raw,
                    raw: soapenv:Envelope xmlns:soapenv=\http://schemas.xmlsoap.org/soap/envelope/\ xmlns:job=\http://xxx xmlns:job1=\http://schemas.datacontract.org/2004/07/JobAdService.DataContract\\r\n   soapenv:Header\r\n      job:Credentials\r\n         job1:Passwordxxx/job1:Password\r\n         job1:Usernamexxx/job1:Username\r\n      /job:Credentials\r\n   /soapenv:Header\r\n   soapenv:Body\r\n      job:SearchJobRequestType\r\n         job:SearchParameters\r\n            job:CreatedFrom2022-01-01T00:00:00+02:00/job:CreatedFrom\r\n            job:CreatedTo2022-12-31T00:00:00+01:00/job:CreatedTo\r\n            job:JobAttributes\r\n               job:JobAttributeHotjob/job:JobAttribute\r\n            /job:JobAttributes\r\n            job:StatusPublication/job:Status\r\n         /job:SearchParameters\r\n      /job:SearchJobRequestType\r\n   /soapenv:Body\r\n/soapenv:Envelope
                },
                url: {
                    raw: https://xxx.svc,
                    protocol: https,
                    host: [
                        jobt1,
                        jobnettest,
                        dk
                    ],
                    path: [
                        JobAdService,
                        v3,
                        JobAdService.svc
                    ]
                }
            },
            response: []
        }
    ]
}

How can I make this script fire in WordPress PHP and then store the file locally on the webserver in either XML or JSON with the response?

The Search method finds all the job ID's with the given attribute, and the Get method afterwards has to use these ID's to make a list of all the job details for each job.

Topic xml soap json Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.