我尝试将一些带有cfhttp
的XML传递给API:
<cfxml variable="elementvalue">
<entry name='DENY_TEST'>
<to>
<member>Public</member>
</to>
<from>
<member>VPN_CLIENTS</member>
</from>
<source>
<member>any</member>
</source>
<destination>
<member>any</member>
</destination>
<source-user>
<member>any</member>
</source-user>
<category>
<member>any</member>
</category>
<application>
<member>bittorrent</member>
<member>skype</member>
</application>
<service>
<member>application-default</member>
</service>
<hip-profiles>
<member>any</member>
</hip-profiles>
<action>deny</action>
<rule-type>universal</rule-type>
<disabled>no</disabled>
</entry>
</cfxml>
这是我尝试的cfhttp
来电:
<cfhttp method="post" url="https://domain.com/api" result="objGet" throwonerror="Yes">
<cfhttpparam name="type" type="formfield" value="config" />
<cfhttpparam name="action" type="formfield" value="set" />
<cfhttpparam name="key" type="formfield" value="LUZReHB3TVlyYrODNENGVpRmYvVmEvWW5uVjBzZHo4cz0=" />
<cfhttpparam name="xpath" type="formfield" value="/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules" />
<cfhttpparam name="element" type="formfield" value="#elementvalue#" />
</cfhttp>
如果我在浏览器中使用它,一切正常,我就会成功。
https://domain.com/api/?type=config&action=set&key=LUZReHB3TVlyYrODNENGVpRmYvVmEvWW5uVjBzZHo4cz0=&xpath==/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules&element=<entry name="DENY_TEST"><to><member>Public</member></to><from><member>VPN_CLIENTS</member></from><source><member>any</member></source><destination><member>any</member></destination><source-user><member>any</member></source-user><category><member>any</member></category><application><member>bittorrent</member><member>skype</member></application><service><member>application-default</member></service><hip-profiles><member>any</member></hip-profiles><action>deny</action><rule-type>universal</rule-type><disabled>no</disabled></entry>
知道为什么会失败吗?它停在元素上。我是否正确使用cfxml
或者我应该尝试使用带有反斜杠的变量?
答案 0 :(得分:0)
问题在于设备上的ssl证书。我没有想过用http优先测试它。要使用ssl,我必须在CF的密钥库中导入设备的证书。我还使用以下内容将xml存储在变量中:
<cfsavecontent variable="elementvalue"><entry name='DENY_TEST'>
<to>
<member>Public</member>
</to>
<from>
<member>VPN_CLIENTS</member>
</from>
<source>
<member>any</member>
</source>
<destination>
<member>any</member>
</destination>
<source-user>
<member>any</member>
</source-user>
<category>
<member>any</member>
</category>
<application>
<member>bittorrent</member>
<member>skype</member>
</application>
<service>
<member>application-default</member>
</service>
<hip-profiles>
<member>any</member>
</hip-profiles>
<action>deny</action>
<rule-type>universal</rule-type>
<disabled>no</disabled>
</entry>
</cfsavecontent>