我正在尝试创建一个Sub品牌(使用自编写的SOAP客户端)。
on wsdl SoftLayer_Brand#createObject要求参数templateObject
是tns:SoftLayer_Brand
在xsd文件上检查这个复杂类型我得到了文件类型,并且我传递了以下哈希来请求
longName: "Company Long Name",
name: "Company Name",
keyName: "KEY_NAME",
account: {
address1: "123 5th Street",
city: "City",
companyName: "Company Name",
country: "US",
email: "user@mail.com",
firstName: "First",
lastName: "Last",
officePhone: '1234-1234',
postalCode: "11011",
state: "NY"
}
我的客户端使用以下XML
发送请求<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://api.service.softlayer.com/soap/v3/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<authenticate>
<username>SL00000</username>
<apiKey>apikeyhash</apiKey>
</authenticate>
</env:Header>
<env:Body>
<tns:createObject>
<templateObject>
<longName>Company Long Name</longName>
<name>Company Name</name>
<keyName>KEY_NAME</keyName>
<account>
<address1>123 5th Street</address1>
<city>City</city>
<companyName>Company Name - Master Account</companyName>
<country>US</country>
<email>user@mail.com</email>
<firstName>First</firstName>
<lastName>Last</lastName>
<officePhone>1234-1234</officePhone>
<postalCode>11011</postalCode>
<state>NY</state>
</account>
</templateObject>
</tns:createObject>
</env:Body>
</env:Envelope>
我之前创建了Sub Brands,但它已经不能使用了,如果缺少任何参数,请指点我。
在雾 - 软层上,我们创建这种方式https://github.com/fog/fog-softlayer/blob/master/examples/account.md#create-a-connection-to-softlayer-account-service(免责声明:我是雾软件维护者之一)
尝试使用此(旧)要点[{3}}上显示的参数,但也没有效果。
只是想知道某些内容是否已更改或是否已对参数应用任何验证。
谢谢
答案 0 :(得分:1)
好的,我想我弄明白了。
1:您正在使用api的v3版本,虽然这通常不是问题,但您需要在此处使用v3.1。
2:在标题中,您将SL SOAP定义包含在xmlns:tns =&#34;&#34;中,因此您需要使用xsi:type =&#34; tns:SoftLayer_Brand&#34; 或者您可以使用xmlns:v3 =&#34; http://api.service.softlayer.com/soap/v3.1/"和xsi:type =&#34; v3:SoftLayer_Brand&#34;
此调用有效
curl -d @createBrand.soap.xml https://api.softlayer.com/soap/v3.1/SoftLayer_Brand
createBrand.soap.xml
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://api.service.softlayer.com/soap/v3.1/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<authenticate>
<username>SL1234</username>
<apiKey>kkeeyy</apiKey>
</authenticate>
</env:Header>
<env:Body>
<createObject >
<templateObject xsi:type="tns:SoftLayer_Brand">
<longName>Company Long Name</longName>
<name>Company Name</name>
<keyName>KEY_NAME</keyName>
<account>
<address1>123 5th Street</address1>
<city>City</city>
<companyName>Company Name - Master Account</companyName>
<country>US</country>
<email>user@mail.com</email>
<firstName>First</firstName>
<lastName>Last</lastName>
<officePhone>1234-1234</officePhone>
<postalCode>11011</postalCode>
<state>NY</state>
</account>
</templateObject>
</createObject>
</env:Body>
</env:Envelope>
答案 1 :(得分:0)
createObject
中添加了一些属性:
<强>其中:强>
启用acknowledgementRequiredFlag
并添加新策略后,当用户登录门户时(用户需要查看支持策略),将显示此策略。否则,可以禁用此选项(用户不需要查看支持策略)。
policyId
有两种政策类型:
”SoftLayer Indirect Support Policy” with id = 101
和SoftLayer Standard Support Policy with id=1
(我没有找到与这些选项相关的信息)。
下面是一个SOAP示例:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v3="http://api.service.softlayer.com/soap/v3/">
<soapenv:Header>
<SoftLayer_BrandObjectMask xsi:type="v3:SoftLayer_BrandObjectMask">
<mask xsi:type="v3:SoftLayer_Brand"/>
</SoftLayer_BrandObjectMask>
<authenticate xsi:type="v3:authenticate">
<username xsi:type="xsd:string">?</username>
<apiKey xsi:type="xsd:string">?</apiKey>
</authenticate>
</soapenv:Header>
<soapenv:Body>
<v3:createObject soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<templateObject xsi:type="v3:SoftLayer_Brand">
<keyName xsi:type="xsd:string">KEY_NAME</keyName>
<longName xsi:type="xsd:string">Company Long Name</longName>
<name xsi:type="xsd:string">Company Name</name>
<account xsi:type="ns1:SoftLayer_Account">
<address1 xsi:type="xsd:string">123 5th Street</address1>
<city xsi:type="xsd:string">Dallas</city>
<companyName xsi:type="xsd:string">test Company Name</companyName>
<country xsi:type="xsd:string">US</country>
<email xsi:type="xsd:string">user@testmail.com</email>
<firstName xsi:type="xsd:string">FirstName</firstName>
<lastName xsi:type="xsd:string">LastName</lastName>
<officePhone xsi:type="xsd:string">591789611111</officePhone>
<postalCode xsi:type="xsd:string">32124</postalCode>
<state xsi:type="xsd:string">NY</state>
</account>
<supportPolicyAssignment xsi:type="ns1:SoftLayer_Policy_Brand">
<acknowledgementRequiredFlag xsi:type="xsd:int">1</acknowledgementRequiredFlag>
<policyId xsi:type="xsd:int">101</policyId>
</supportPolicyAssignment>
</templateObject>
</v3:createObject>
</soapenv:Body>
</soapenv:Envelope>
我希望它可以帮到你。