SOAP API question


(Mahearnpad) #1

Hi


Is there any way that I can change the "transformations" setting, programmatically, on an xml file that is dumped into Matrix via the SOAP API?



I have an existing xsl file in place, and I need to dump around 2000 xml files into a directory, and have them all be transformed into html via the xsl file. Doesn't seem possible, looking at the manual, but then I've often missed obvious things before. Has anyone got any suggestions?



Michael


(Benjamin Pearson) #2

[quote]
Hi



Is there any way that I can change the "transformations" setting, programmatically, on an xml file that is dumped into Matrix via the SOAP API?



I have an existing xsl file in place, and I need to dump around 2000 xml files into a directory, and have them all be transformed into html via the xsl file. Doesn't seem possible, looking at the manual, but then I've often missed obvious things before. Has anyone got any suggestions?



Michael

[/quote]



Yep, the transformations on an xml file is a NOTICE link between the XML file and its XSL file (with a link value of 'transform'). So in SOAP (in PHP) you would do something like:

    
    $client = new SoapClient($url, $options);
    $client->CreateAssetLink(array(
    'MajorID'   => XML_FILE_ASSETID,
    'MinorID'   => XSL_FILE_ASSETID,
    'LinkType'  => 4,
    'LinkValue' => 'transform',
    ));


* Forgot to mention, if there is already a transformation on the XML file, you would have to delete then re-add.

(Mahearnpad) #3

Thank you so much Benjamin


I was getting ready to give up. You're a genius!



Michael


[quote]

Yep, the transformations on an xml file is a NOTICE link between the XML file and its XSL file (with a link value of 'transform'). So in SOAP (in PHP) you would do something like:

    
    $client = new SoapClient($url, $options);
    $client->CreateAssetLink(array(
    'MajorID'   => XML_FILE_ASSETID,
    'MinorID'   => XSL_FILE_ASSETID,
    'LinkType'  => 4,
    'LinkValue' => 'transform',
    ));


* Forgot to mention, if there is already a transformation on the XML file, you would have to delete then re-add.
[/quote]

(Mahearnpad) #4

Funny. From this code:

[quote]$createAssetLink = array(

'MajorID' => '138149', //id of the xml file

'MinorID' => $xslAssetID, //id of the xsl file

'LinkType' => 4,

'LinkValue' => 'transform'

);



$linkResult = $client->createAssetLink($createAssetLink);

[/quote]



I'm getting this error back:

[quote]Fatal error: Uncaught exception 'Exception' with message 'SOAP fault encountered: Unable to Create link: Assets of Type "xsl_file" cannot be "TYPE_3" linked to a "xml_file" [SYS0301]' in /home/nps/public_html/MatrixSOAP/CMI_webservices/SetXMLAttributeValues.php:65 Stack trace: #0 {main} thrown in /home/nps/public_html/MatrixSOAP/CMI_webservices/SetXMLAttributeValues.php on line 65[/quote]



It mentions Type_3 - where I've clearly passed in a 4 as the link type parameter. I'm wondering, does this work in our version of Matrix - we're currently still on version 3.28?






[quote]

Yep, the transformations on an xml file is a NOTICE link between the XML file and its XSL file (with a link value of 'transform'). So in SOAP (in PHP) you would do something like:

    
    $client = new SoapClient($url, $options);
    $client->CreateAssetLink(array(
    'MajorID'   => XML_FILE_ASSETID,
    'MinorID'   => XSL_FILE_ASSETID,
    'LinkType'  => 4,
    'LinkValue' => 'transform',
    ));


* Forgot to mention, if there is already a transformation on the XML file, you would have to delete then re-add.
[/quote]

(Greg Sherwood) #5

Link type numbers are bitwise. So they would go:
type_1 = 1

type_2 = 2

type_3 = 4

notice = 8



So you'll need to use 8 in this case.


(Mahearnpad) #6

Thanks Greg that works!


These little bits of necessary information are not (or don't appear to be) in the manual, so I always have to ask.



Michael


[quote]

Link type numbers are bitwise. So they would go:

type_1 = 1

type_2 = 2

type_3 = 4

notice = 8



So you'll need to use 8 in this case.

[/quote]


(Greg Sherwood) #7

[quote]
These little bits of necessary information are not (or don't appear to be) in the manual, so I always have to ask.

[/quote]



Status codes are in the manual but I think you're right about the link types being left out. I'll prod the right person.



But we're always happy to answer questions as well :slight_smile:


(Benjamin Pearson) #8

[quote]
Status codes are in the manual but I think you're right about the link types being left out. I'll prod the right person.



But we're always happy to answer questions as well :slight_smile:

[/quote]



My bad, I didn't pick up on it earlier, I was reading directly from a manual page which was incorrect :blink: , will get it fixed up.