我正在开发一个用于quickbooks的集成Web服务。我已经能够找出所有的添加和查询字符串,但我无法弄清楚如何正确发送mod请求。我知道我的请求与我的xml字符串有问题,因为我没有收到来自Web连接器的响应。我试图按照屏幕上的参考最好,但由于某种原因,它仍然无法正常工作。
以下是来自连接器的查询响应字符串:
`<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<CustomerQueryRs requestID="183" statusCode="0" statusSeverity="Info" statusMessage="Status OK">
<CustomerRet>
<ListID>80000062-1431710964</ListID>
<TimeCreated>2015-05-15T11:29:24-07:00</TimeCreated>
<TimeModified>2015-05-15T11:29:24-07:00</TimeModified>
<EditSequence>1431710964</EditSequence>
<Name>Test 2 Contractor, Inc.</Name>
<FullName>Test 2 Contractor, Inc.</FullName>
<IsActive>true</IsActive>
<Sublevel>0</Sublevel>
<CompanyName>Test 2 Contractor, Inc.</CompanyName>
<BillAddress>
<Addr1>Test bill 1</Addr1>
<Addr2>Test bill 2</Addr2>
<City>Test City</City>
<State>UT</State>
<PostalCode>84057</PostalCode>
<Country>USA</Country>
</BillAddress>
<BillAddressBlock>
<Addr1>Test bill 1</Addr1>
<Addr2>Test bill 2</Addr2>
<Addr3>Test City, Utah 84057</Addr3>
<Addr4>United States</Addr4>
</BillAddressBlock>
<ShipAddress>
<Addr1>Test ship 1</Addr1>
<Addr2>Test ship 2</Addr2>
<City>Test City</City>
<State>UT</State>
<PostalCode>84057</PostalCode>
<Country>USA</Country>
</ShipAddress>
<ShipAddressBlock>
<Addr1>Test ship 1</Addr1>
<Addr2>Test ship 2</Addr2>
<Addr3>Test City, Utah 84057</Addr3>
<Addr4>United States</Addr4>
</ShipAddressBlock>
<ShipToAddress>
<Name>Ship To 1</Name>
<Addr1>Test ship 1</Addr1>
<Addr2>Test ship 2</Addr2>
<City>Test City</City>
<State>UT</State>
<PostalCode>84057</PostalCode>
<Country>USA</Country>
<DefaultShipTo>true</DefaultShipTo>
</ShipToAddress>
<Phone>555-555-5555</Phone>
<AltPhone>555-555-5554</AltPhone>
<Fax>555-555-5553</Fax>
<Email>business@mail.com</Email>
<AdditionalContactRef>
<ContactName>Main Phone</ContactName>
<ContactValue>555-555-5555</ContactValue>
</AdditionalContactRef>
<AdditionalContactRef>
<ContactName>Alt. Phone</ContactName>
<ContactValue>555-555-5554</ContactValue>
</AdditionalContactRef>
<AdditionalContactRef>
<ContactName>Fax</ContactName>
<ContactValue>555-555-5553</ContactValue>
</AdditionalContactRef>
<AdditionalContactRef>
<ContactName>Main Email</ContactName>
<ContactValue>business@mail.com</ContactValue>
</AdditionalContactRef>
<Balance>0.00</Balance>
<TotalBalance>0.00</TotalBalance>
<JobStatus>None</JobStatus>
<PreferredDeliveryMethod>None</PreferredDeliveryMethod>
</CustomerRet>
</CustomerQueryRs>
</QBXMLMsgsRs>
</QBXML>`
这是我发送给连接器的mod请求:
`<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<CustomerModRq requestID="184">
<CustomerMod>
<ListID>80000062-1431710964</ListID>
<EditSequence>1431710964</EditSequence>
<Name>Test 2 Contractor, Inc.Updated</Name>
<CompanyName>Test 2 Contractor, Inc.</CompanyName>
</CustomerMod>
</CustomerModRq>
</QBXMLMsgsRq>
</QBXML>`
以下是我用于生成xml的代码:
$mod_info = json_decode($queue_set['qb_queue_item']->extra);
$list_id = $mod_info->list_id;
$edit_sequence = $mod_info->edit_sequence;
//Get the contractor to be sent to quickbooks
$contractor = new Contractor();
if(!($contractor = $contractor::find($queue_set['kyco_queue_item']->obj_id)))
return array('status' => $this::STATUS_ERROR, 'data' => "Failed to find contractor in the database");
if(!isset($contractor->contractor))
return array('status' => $this::STATUS_ERROR, 'data' => "Contractor does not have a valid name");
/*$address_billing = Address::Primary(get_class($contractor), $contractor->id, Address::ADDRESS_TYPE_BILLING);
$address_shipping = Address::Primary(get_class($contractor), $contractor->id, Address::ADDRESS_TYPE_SHIPPING);
$phone_primary = PhoneNumber::Primary(get_class($contractor), $contractor->id, PhoneNumber::PHONE_TYPE_STATIC);
$phone_alt = PhoneNumber::Primary(get_class($contractor), $contractor->id, PhoneNumber::PHONE_TYPE_MOBILE);
$phone_fax = PhoneNumber::Primary(get_class($contractor), $contractor->id, PhoneNumber::PHONE_TYPE_FAX);
$email = Email::Primary(get_class($contractor), $contractor->id, Email::EMAIL_TYPE_BUSINESS);*/
// Build the qbXML request from the contractors data
$xml = "";
$xml .= '<?xml version="1.0" encoding="utf-8"?>'. LINE_RETURN;
$xml .= '<?qbxml version="13.0"?>'. LINE_RETURN;
$xml .= '<QBXML>'. LINE_RETURN;
$xml .= LINE_TAB . '<QBXMLMsgsRq onError="stopOnError">'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . '<CustomerModRq requestID="' . $queue_set['qb_queue_item']->quickbooks_queue_id . '">'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . '<CustomerMod>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<ListID>' . $list_id . '</ListID>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<EditSequence>' . $edit_sequence . '</EditSequence>'. LINE_RETURN;
//$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<Name>' . $contractor->contractor . "Updated". '</Name>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<CompanyName>' . $contractor->contractor . '</CompanyName>'. LINE_RETURN;
/*if($address_billing)
{
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<BillAddress>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<Addr1>' . $address_billing->address_1 . '</Addr1>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<Addr2>' . $address_billing->address_2 . '</Addr2>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<City>' . $address_billing->city . '</City>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<State>' . $address_billing->state . '</State>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<PostalCode>' . $address_billing->postal_code . '</PostalCode>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<Country>' . $address_billing->country . '</Country>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '</BillAddress>'. LINE_RETURN;
}
if($address_shipping)
{
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<ShipAddress>' . LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<Addr1>' . $address_shipping->address_1. '</Addr1>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<Addr2>' . $address_shipping->address_2 . '</Addr2>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<City>' . $address_shipping->city . '</City>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<State>' . $address_shipping->state . '</State>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<PostalCode>' . $address_shipping->postal_code . '</PostalCode>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<Country>' . $address_shipping->country . '</Country>' . LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '</ShipAddress>' . LINE_RETURN;
}
if($phone_primary)
{
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<Phone>' . $phone_primary->number . '</Phone>'. LINE_RETURN;
}
if($phone_alt)
{
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<AltPhone>' . $phone_alt->number . '</AltPhone>'. LINE_RETURN;
}
if($phone_fax)
{
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<Fax>' . $phone_fax->number . '</Fax>'. LINE_RETURN;
}
if($email)
{
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . LINE_TAB . '<Email>' . $email->email . '</Email>'. LINE_RETURN;
}*/
$xml .= LINE_TAB . LINE_TAB . LINE_TAB . '</CustomerMod>'. LINE_RETURN;
$xml .= LINE_TAB . LINE_TAB . '</CustomerModRq>'. LINE_RETURN;
$xml .= LINE_TAB . '</QBXMLMsgsRq>'. LINE_RETURN;
$xml .= '</QBXML>'. LINE_RETURN;
//get the relational entry attached to the quickbooks queue id ($qb_queue_id)
$queue_set['kyco_queue_item']->status = KycoQueueItem::STATUS_MOD_SENT;
$queue_set['kyco_queue_item']->save();
return array('status' => $this::STATUS_SUCCESS, 'data' => $xml);
返回到我的映射客户mod请求函数。
这是我的网络连接器日志文件:
https://drive.google.com/file/d/0B5iqqn5sniRDTGpJbkhKZDl6cTA/view?usp=sharing
我的php日志文件没有任何报告。 Apache Log没有任何报告,我发布的那两个xml字符串都是我在xml离开Web连接器之前打印到日志的log_message消息。
我能想到的另一件事可能是相关的是,在我完成对listID和EditSequence的查询之后,我将这些存储在我新排队的mod请求的额外字段中的json字符串中,这样我就可以将它们取回当我生成mod请求时再次。发送请求时,该字符串会保留在那里。可能会以某种方式弄乱它吗?
我的集成是通过quickbooks web连接器为quickbooks企业解决方案承包商15.0
完成的