donz365 42 Light Poster

Thanks Cereal for helping with this.

The problem was my client was sending back extra charaters which were causing errors. These articles explain it in detail...

qa-byte-order-mark
detecting-utf-bom-byte-order-mark

I was still struggling to get the result I needed but the following solution from Cereal worked perfect, it emulates a Soap client and although it may not be an ideal solution for everyone because it requires more code its works for me!!!

<?php
    $wsdl   = "https://your-WSDL-address.com/courseinfo/courseinfo.asmx";
    $soap   = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://your-WSDL-address.com/"><SOAP-ENV:Body><ns1:getCourseInfo><ns1:centre>CO</ns1:centre></ns1:getCourseInfo></SOAP-ENV:Body></SOAP-ENV:Envelope>
EOD;
    $length = strlen($soap);
    $header = array(
        "Host: your-WSDL-address.com",
        "Connection: Keep-Alive",
        "User-Agent: PHP-SOAP/5.5.9-1ubuntu4.9",
        "Content-type: text/xml;charset=utf-8",
        "Accept: text/xml",
        "Cache-Control: no-cache",
        "Pragma: no-cache",
        "SOAPAction: \"http://your-WSDL-address.com/getCourseInfo\"",
        "Content-Length: ".$length,
        );
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL,            $wsdl);
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($curl, CURLOPT_TIMEOUT,        10);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true );
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_POST,           true );
    curl_setopt($curl, CURLOPT_POSTFIELDS,     $soap);
    curl_setopt($curl, CURLOPT_HTTPHEADER,     $header);
    # show request and response headers
    curl_setopt($curl, CURLOPT_VERBOSE,        true);
    $response = curl_exec($curl);
    if($response === false) {
        $err = 'Curl error: ' . curl_error($curl);
        curl_close($curl);
        print PHP_EOL;
        print $err;
        print PHP_EOL;
    } else {
        curl_close($curl);
        print 'Operation completed without any errors';
        print PHP_EOL;
        $load = simplexml_load_string($response);
        # loading the namespace
        $resp = $load->children("http://schemas.xmlsoap.org/soap/envelope/");
        print_r($resp->Body->children());
    }
cereal commented: you're welcome! +13
donz365 42 Light Poster

Slight tweak and its working... thanks Diafol :/

LOAD XML LOCAL INFILE 'C:/courses.xml' 
INTO TABLE wp_posts ROWS IDENTIFIED BY '<Course>'
(@ReferenceNo, @ProviderCode, @ProviderName, @CourseID, @CourseName, @LocationCode, @LocationName, @StartDate, @FinishDate)
SET ID = @ReferenceNo,
    post_title = @CourseName,
    post_type = 'course';
diafol commented: Great! Thanks for sharing +15
donz365 42 Light Poster

Hi Diafol,

Thanks for your reply. I have applied the SET clause like so:

LOAD XML LOCAL INFILE 'C:/courses.xml' 
INTO TABLE wp_posts ROWS IDENTIFIED BY '<Course>'
SET ID = ReferenceNo,
    post_title = CourseName,
    post_type = 'course';

And I get the following error:

1054 - Unknown column 'ReferenceNo' in 'field list'

This is a snippet of the xml

<?xml version="1.0" encoding="utf-8"?>
    <Course>
    <ReferenceNo>64055</ReferenceNo>
    <ProviderCode>CO</ProviderCode>
    <ProviderName>name deleted</ProviderName>
    <CourseID>CO43Z</CourseID>
    <CourseName>IT Maintenance - Short Course</CourseName>
    <CourseTypeID>1</CourseTypeID>
    <CourseTypeName>1</CourseTypeName>
    <LocationCode>70203</LocationCode>
    <LocationName>name deleted </LocationName>
    <StartDate>2015.12.07</StartDate>
    <FinishDate>2016.03.04</FinishDate>
  </Course>
iamthwee commented: I'd hit it +14
donz365 42 Light Poster

uum theres an idea for an App :)

If the white is part of the image you will have to edit it in Photoshop by selecting and deleting the background and save as a .png.

If the white part is the color of the div the image is in did you try setting the background color to transparent in css

.nameOfDivClass{background-color: transparent;}

donz365 42 Light Poster

Hi,

I have been trying to research something similar (i think), I found this tut very good to help me understand SOAP better.

Donna :)