2
我不知道如果我要在這裏發佈,但我想使用Python來請求給Mouser的車API和皁液庫Mouser的車API請求
def updateCart():
url = "https://mews.mouser.com/cartservice.asmx?op=UpdateCart&wsdl"
client = Client(url)
xmlns = Attribute("xmlns", "http://tempuri.org/XMLSchema.xsd")
xmlnsXSD = Attribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema")
xmlnsXSI = Attribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
cartGUID = Attribute("CartGUID", "")
requestor = Attribute("Requestor", "richeve")
cartMessage = Element("CartMessage") \
.append(xmlns) \
.append(xmlnsXSD) \
.append(xmlnsXSI) \
.append(cartGUID)\
.append(requestor)
partNumber = Attribute("MouserPartNumber", "941-CCS050M12CM2")
quantity = Attribute("Quantity", "5")
cartItem = Element("CartItem").append(partNumber).append(quantity)
cartMessage.append(cartItem)
xmlCartMessage = Element("xmlCartMessage").append(cartMessage)
result = client.service.UpdateCart(xmlCartMessage)
print result
print client
return True
的這個問題是我總是讓手術超時。我不知道他們的API或服務器是否發生故障。或者我在我的代碼中缺少一些東西。