2016-03-01 84 views
1

我正尝试创建一个Sub品牌(使用自写的SOAP客户端)。在SoftLayer API(返回#500的API)上创建子品牌帐户

在WSDL SoftLayer_Brand#创建对象要求的参数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: "[email protected]", 
    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>[email protected]</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> 

我创建子品牌之前发送请求,但它不是工作了,请你指出我是否缺少任何参数。

在雾SOFTLAYER我们创造这样https://github.com/fog/fog-softlayer/blob/master/examples/account.md#create-a-connection-to-softlayer-account-service(免责声明:我雾SOFTLAYER维护者之一)

试图与参数显示在此(旧)依据https://gist.github.com/underscorephil/377bd50e71ac02377008并没有工作过。

只想知道是否有更改或任何验证正在应用于参数。

谢谢

回答

1

好的,我想我已经明白了。

1:您正在使用api的v3版本,虽然此USUALLY不是问题,但您需要在此处使用v3.1。

2:在你的头,你包括的xmlns的SL SOAP定义:TNS = “”,所以你需要使用的xsi:type = “TNS:SoftLayer_Brand” 或者你可以使用的xmlns:V3 =” http://api.service.softlayer.com/soap/v3。1 /”和XSI:类型= “V3:SoftLayer_Brand”

此调用工作

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>[email protected]</email> 
     <firstName>First</firstName> 
     <lastName>Last</lastName> 
     <officePhone>1234-1234</officePhone> 
     <postalCode>11011</postalCode> 
     <state>NY</state> 
    </account> 
    </templateObject> 
    </createObject> 
    </env:Body> 
</env:Envelope> 
+0

似乎SoftLayer WSDL是rpc/encoded(据我研究),而我用来支持SOAP操作的库只支持文档/文字,我增加了对rpc/encoded的支持,现在事情运行良好。谢谢! –

0

有些属性是在createObject补充说:

  • acknowledgementRequiredFlag和
  • 策略ID

其中:

acknowledgementRequiredFlag已启用并添加新策略,则当用户登录到门户时将显示此策略(用户需要查看支持策略)。否则,可以禁用此选项(用户不需要查看支持策略)。

policyId有两种政策类型: ”SoftLayer Indirect Support Policy” with id = 101SoftLayer 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">[email protected]</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> 

我希望它帮你。

+0

喜mcruz,遗憾的是它没有工作,发送完全你的XML(与我的数据)API返回错误的请求。任何进一步的建议吗?谢谢 –

+0

在我的请求我刚添加'xsi:type =“v3:SoftLayer_Brand”'键入模板对象并收到一个错误的请求 –

+0

它看起来很奇怪,我再次执行SOA P要求,它运作良好。目前我正在使用SOAP UI,客户请求和我发送的请求之间的唯一区别在于,列出的所有属性都有“xsi:type”(即我的情况: FirstName,客户案例:第一个)。请再次尝试客户端的请求,只添加“supportPolicyAssignment”(带有“acknowledgementRequiredFlag”和“policyId”)的部分,避免使用“xsi:type”。 – mcruz

相关问题