Set the page contents of a bodycopy using SOAP


(D Black) #1
Hello, I'm trying to use the SOAP API to set some page content. I'm able to use the SetAttributeValue as per the doco (http://manuals.matrix.squizsuite.net/web-services/chapters/soap-api-asset-service#setattributevalue) and this old topic (http://forums.squizsuite.net/index.php?showtopic=8041), but the web service seems to be escaping the html content i send up to it. The SOAP request I'm sending is as follows (note the attribute value):
 
<SOAP-ENV:Envelope ...>
    <SOAP-ENV:Body>
        <ns1:SetAttributeValue>
            <AssetID xsi:type="xsd:string">25336</AssetID>
            <AttributeName xsi:type="xsd:string">html</AttributeName>
            <AttributeValue><![CDATA[<h2>testing 9!</h2>]]></AttributeValue>
        </ns1:SetAttributeValue>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
 
And the response i'm getting back is:
 
<SOAP-ENV:Envelope ...>
    <SOAP-ENV:Body>
        <ns1:SetAttributeValueResponse>
            <SetAttributeValueResult>&amp;lt;h2&amp;gt;testing 9!&amp;lt;/h2&amp;gt;</SetAttributeValueResult>
        </ns1:SetAttributeValueResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
 
Any ideas? I'm probably going to head down the path of creating a metadata scheme for this page, and setting the page contents using the SetAssetMetadata SOAP service (and hoping that html is not escaped!).

(Talk) #2

Hey mate, could be a number of things, one thing to check is your GlobalPreferences settings. There should be a "Filter Front End User Input" option, is it disabled?


(Nic Hubbard) #3

I did extensive SOAP API work, including setting HTML as an Attribute, but I never ran into this. Are you sure that whatever method you are using to send the request, that it isn't converting those? How are you in fact sending the request?


(D Black) #4

Thanks for your responses!

 

Jeremy, I don't seem to have access to the GlobalPreferences settings - we're being hosted by Squiz, so perhaps that's locked down? We're also on an older version (4.18.0) so perhaps the settings aren't in the same place as mentioned in the documentation.

 

Nic, I'm *pretty sure* that I have ruled out my client as escaping the html (I'm using the PHP SoapClient). It was originally, i can see the last request using SoapClient::__getLastRequest, but then i found a different way to add the attribute values using SoapVar, and __getLastRequest now returns the request as shown in my first post. Here is a snippet of the test code that i'm using to call the service:

 

    $client = new \SoapClient(null, array(
            "uri" => "http://my_web_service/_web_services/soap_server",
            "location" => "http://my_web_service/_web_services/soap_server",
            "trace" => 1,
            'login'    => $argv[1],
            'password' => $argv[2],
            )
        );
 
    $response = $client->SetAttributeValue(
        new \SoapParam('25336', 'AssetID'),
        new \SoapParam('html', 'AttributeName'),
        new \SoapVar('<AttributeValue xsi:type="xsd:string"><![CDATA[<h2>testing 9!</h2>]]></AttributeValue>', XSD_ANYXML)
    );
 
    print_r($client->__getLastRequest());
    print_r($client->__getLastResponse());

 

I appreciate your input!


(Nic Hubbard) #5

Yeah, I am not sure. I would use a SOAP Client app to test the function first, and if all goes well, then you can trace back to the issue being caused by the PHP SoapClient.


(Benjamin Pearson) #6

What about trying:

$response = $client->SetAttributeValue(array('AssetID' => '25336', 'AttributeName' => 'html', 'AttributeValue' => '<h2>testing 9!</h2>'));

 

Maybe it could be forming with \SoapParam and \SoapVar that is the problem?


(D Black) #7

Hi Benjamin, that was how i was originally using the SoapClient, but tried using SoapVar as the SoapClient appeared to be escaping the request.

 

I believe i have confirmed the problem is with Squiz, as i have replicated the issue using Curl to send up a raw soap request. I'll submit a support request to look into the global preferences that Jeremy suggested.


(D Black) #8

Jeremy, you hit the nail on the head. The "Filter Front End User Input" preference does effect soap api calls, so i'm going to look at a couple of options to see what i can do (preferring not to change that setting for security reasons)


(Nic Hubbard) #9

You can create a User Group and set the preferences to turn that feature off for just those set users.


(D Black) #10

Oh sweet! I'll have a look at that.


(D Black) #11

Yes Nic, that's solved that issue, many thanks!