首页 > 请问如何通过API接口向服务器数据库中插入数据?

请问如何通过API接口向服务器数据库中插入数据?

1.当我向服务器提交数据是,返回true,
2.但是刷新数据库,发现数据插入没有成功,为空。

asp.api 代码

<!--#include file="conn.asp" -->
<!--#include file="md5_utf8.asp" -->
<%
Response.Charset = "UTF-8"
Server.ScriptTimeOut=500000
logistics_interface=Trim(Request("logistics_interface"))
logistic_provider_id=Trim(Request("logistic_provider_id"))
msg_type=Trim(Request("msg_type"))
data_digest=Trim(Request("data_digest"))

Function xml_val(str1,str2,str3)

str1s=str1
'str1s=Replace(str1s,"&","[and]")
'str1s=Replace(str1s,"#","[jinhao]")
if str3<>"" then
    if instr(str1s,"<"&str3&">")>0 and instr(str1s,"</"&str3&">")>0 then
        str1s=mid(str1s,instr(str1s,"<"&str3&">"),instr(str1s,"</"&str3&">")-instr(str1s,"<"&str3&">"))
        str1s=Replace(str1s,"<"&str3&">","")
    end if
end if
if instr(str1s,"<"&str2&">")>0 and instr(str1s,"</"&str2&">")>0 then
    str0=mid(str1s,instr(str1s,"<"&str2&">"),instr(str1s,"</"&str2&">")-instr(str1s,"<"&str2&">"))
    str0=Replace(str0,"<"&str2&">","")
end if
str0=Replace(str0,"'","''")
'str0=Replace(str0,"[and]","&")
'str0=Replace(str0,"[jinhao]","#")
xml_val=str0

End Function
'conn.execute "insert into xml (xml) values ('"&logistics_interface&"')"

if msg_type="LOGISTICS_PACKAGE_SEND" then

conn.execute "insert into receiver(eventType,eventTime,eventSource,eventTarget,mailNo,orderCode,remark,domesticExpressId,domesticExpressCode,domesticExpressName,doorPickup,sendContact_wangwangId,sendContact_name,sendContact_phone,sendContact_mobile,sendContact_email,sendContact_idenCode,sendContact_country,sendContact_province,sendContact_city,sendContact_district,sendContact_streetAddress,sendContact_areaId,sendContact_zipCode,receiverContact_wangwangId,receiverContact_name,receiverContact_phone,receiverContact_mobile,receiverContact_email,receiverContact_idenCode,receiverContact_country,receiverContact_province,receiverContact_city,receiverContact_district,receiverContact_streetAddress,receiverContact_areaId,receiverContact_zipCode,tradeId,pickupContact_wangwangId,pickupContact_name,pickupContact_phone,pickupContact_mobile,pickupContact_email,pickupContact_idenCode,pickupContact_country,pickupContact_province,pickupContact_city,pickupContact_district,pickupContact_streetAddress,pickupContact_areaId,pickupContact_zipCode,orderCreateTime,subOrder_mailNo,subOrder_mailType,subOrder_interCarrier,subOrder_tradeId,subOrder_orderCode,subOrder_totalltemPrice,subOrder_shipType,subOrder_weight,subOrder_weightLimit,subOrder_remark,subOrder_undeliveryOption,subOrder_hasBattery,subOrder_sendContact_wangwangId,subOrder_sendContact_name,subOrder_sendContact_phone,subOrder_sendContact_mobile,subOrder_sendContact_email,subOrder_sendContact_idenCode,subOrder_sendContact_country,subOrder_sendContact_province,subOrder_sendContact_city,subOrder_sendContact_district,subOrder_sendContact_streetAddress,subOrder_sendContact_areaId,subOrder_sendContact_zipCode,subOrder_receiverContact_wangwangId,subOrder_receiverContact_name,subOrder_receiverContact_phone,subOrder_receiverContact_mobile,subOrder_receiverContact_email,subOrder_receiverContact_idenCode,subOrder_receiverContact_country,subOrder_receiverContact_province,subOrder_receiverContact_city,subOrder_receiverContact_district,subOrder_receiverContact_streetAddress,subOrder_receiverContact_areaId,subOrder_receiverContact_zipCode,itemId,itemName,itemNameCN,itemcategoryName,itemcategoryNameCN,itemUnitPrice,itemQuantity,itemWeight,hasBattery,batteryInfo,inputdate) VALUES ('"&xml_val(logistics_interface,"eventType","")&"','"&xml_val(logistics_interface,"eventTime","")&"','"&xml_val(logistics_interface,"eventSource","")&"','"&xml_val(logistics_interface,"eventTarget","")&"','"&xml_val(logistics_interface,"mailNo","order")&"','"&xml_val(logistics_interface,"orderCode","order")&"','"&xml_val(logistics_interface,"remark","order")&"','"&xml_val(logistics_interface,"domesticExpressId","order")&"','"&xml_val(logistics_interface,"domesticExpressCode","order")&"','"&xml_val(logistics_interface,"domesticExpressName","order")&"','"&xml_val(logistics_interface,"doorPickup","order")&"','"&xml_val(logistics_interface,"wangwangId","sendContact")&"','"&xml_val(logistics_interface,"name","sendContact")&"','"&xml_val(logistics_interface,"phone","sendContact")&"','"&xml_val(logistics_interface,"mobile","sendContact")&"','"&xml_val(logistics_interface,"email","sendContact")&"','"&xml_val(logistics_interface,"idenCode","sendContact")&"','"&xml_val(logistics_interface,"country","sendContact")&"','"&xml_val(logistics_interface,"province","sendContact")&"','"&xml_val(logistics_interface,"city","sendContact")&"','"&xml_val(logistics_interface,"district","sendContact")&"','"&xml_val(logistics_interface,"streetAddress","sendContact")&"','"&xml_val(logistics_interface,"areaId","sendContact")&"','"&xml_val(logistics_interface,"zipCode","sendContact")&"','"&xml_val(logistics_interface,"wangwangId","receiverContact")&"','"&xml_val(logistics_interface,"name","receiverContact")&"','"&xml_val(logistics_interface,"phone","receiverContact")&"','"&xml_val(logistics_interface,"mobile","receiverContact")&"','"&xml_val(logistics_interface,"email","receiverContact")&"','"&xml_val(logistics_interface,"idenCode","receiverContact")&"','"&xml_val(logistics_interface,"country","receiverContact")&"','"&xml_val(logistics_interface,"province","receiverContact")&"','"&xml_val(logistics_interface,"city","receiverContact")&"','"&xml_val(logistics_interface,"district","receiverContact")&"','"&xml_val(logistics_interface,"streetAddress","receiverContact")&"','"&xml_val(logistics_interface,"areaId","receiverContact")&"','"&xml_val(logistics_interface,"zipCode","receiverContact")&"','"&xml_val(logistics_interface,"tradeId","order")&"','"&xml_val(logistics_interface,"wangwangId","pickupContact")&"','"&xml_val(logistics_interface,"name","pickupContact")&"','"&xml_val(logistics_interface,"phone","pickupContact")&"','"&xml_val(logistics_interface,"mobile","pickupContact")&"','"&xml_val(logistics_interface,"email","pickupContact")&"','"&xml_val(logistics_interface,"idenCode","pickupContact")&"','"&xml_val(logistics_interface,"country","pickupContact")&"','"&xml_val(logistics_interface,"province","pickupContact")&"','"&xml_val(logistics_interface,"city","pickupContact")&"','"&xml_val(logistics_interface,"district","pickupContact")&"','"&xml_val(logistics_interface,"streetAddress","pickupContact")&"','"&xml_val(logistics_interface,"areaId","pickupContact")&"','"&xml_val(logistics_interface,"zipCode","pickupContact")&"','"&xml_val(logistics_interface,"orderCreateTime","order")&"','"&xml_val(logistics_interface,"mailNo","subOrder")&"','"&xml_val(logistics_interface,"mailType","subOrder")&"','"&xml_val(logistics_interface,"interCarrier","subOrder")&"','"&xml_val(logistics_interface,"tradeId","subOrder")&"','"&xml_val(logistics_interface,"orderCode","subOrder")&"','"&xml_val(logistics_interface,"totalltemPrice","subOrder")&"','"&xml_val(logistics_interface,"shipType","subOrder")&"','"&xml_val(logistics_interface,"weight","subOrder")&"','"&xml_val(logistics_interface,"weightLimit","subOrder")&"','"&xml_val(logistics_interface,"remark","subOrder")&"','"&xml_val(logistics_interface,"undeliveryOption","subOrder")&"','"&xml_val(logistics_interface,"hasBattery","subOrder")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"wangwangId","sendContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"name","sendContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"phone","sendContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"mobile","sendContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"email","sendContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"idenCode","sendContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"country","sendContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"province","sendContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"city","sendContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"district","sendContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"streetAddress","sendContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"areaId","sendContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"zipCode","sendContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"wangwangId","receiverContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"name","receiverContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"phone","receiverContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"mobile","receiverContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"email","receiverContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"idenCode","receiverContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"country","receiverContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"province","receiverContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"city","receiverContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"district","receiverContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"streetAddress","receiverContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"areaId","receiverContact")&"','"&xml_val(xml_val(logistics_interface,"subOrder","subOrders"),"zipCode","receiverContact")&"','"&xml_val(logistics_interface,"itemId","item")&"','"&xml_val(logistics_interface,"itemName","item")&"','"&xml_val(logistics_interface,"itemNameCN","item")&"','"&xml_val(logistics_interface,"itemcategoryName","item")&"','"&xml_val(logistics_interface,"itemcategoryNameCN","item")&"','"&xml_val(logistics_interface,"itemUnitPrice","item")&"','"&xml_val(logistics_interface,"itemQuantity","item")&"','"&xml_val(logistics_interface,"itemWeight","item")&"','"&xml_val(logistics_interface,"hasBattery","item")&"','"&xml_val(logistics_interface,"batteryInfo","item")&"','"&now()&"')"

elseif msg_type="LOGISTICS_PACKAGE_CANCEL" then

conn.execute "insert into receiver(eventType,eventTime,eventSource,eventTarget,mailNo,orderCode,tradeId,remark,inputdate) VALUES ('"&xml_val(logistics_interface,"eventType","")&"','"&xml_val(logistics_interface,"eventTime","")&"','"&xml_val(logistics_interface,"eventSource","")&"','"&xml_val(logistics_interface,"eventTarget","")&"','"&xml_val(logistics_interface,"mailNo","order")&"','"&xml_val(logistics_interface,"orderCode","order")&"','"&xml_val(logistics_interface,"tradeId","order")&"','"&xml_val(logistics_interface,"remark","order")&"','"&now()&"')"

elseif msg_type="LOGISTICS_REPORT_SEND" then

conn.execute "insert into receiver(eventType,eventTime,eventSource,eventTarget,itemNameCN,itemName,itemQuantity,itemcategoryNameCN,itemcategoryName,itemId,producingArea,itemWeight,itemUnitPrice,ecCompanyId,whCode,pickUpAddress,logisticsOrderId,orderCode,tradeId,mailNo,packageCode,receiverContact_country,receiverContact_province,receiverContact_city,receiverContact_streetAddress,receiverContact_zipCode,receiverContact_name,receiverContact_phone,sendContact_name,sendContact_province,sendContact_city,sendContact_streetAddress,sendContact_phone,sendContact_zipCode,insureValue,insuranceValue,remark,channel,Itotleweight,Itotlevalue,totleweight,hasBattery,sendContact_country,subOrder_mailType,mailClass,batchNo,SMT_mailType,faceType,subOrder_undeliveryOption) VALUES ('"&xml_val(logistics_interface,"eventType","")&"','"&xml_val(logistics_interface,"eventTime","")&"','"&xml_val(logistics_interface,"eventSource","")&"','"&xml_val(logistics_interface,"eventTarget","")&"','"&xml_val(logistics_interface,"productNameCN","product")&"','"&xml_val(logistics_interface,"productNameEN","product")&"','"&xml_val(logistics_interface,"productQantity","product")&"','"&xml_val(logistics_interface,"productCateCN","product")&"','"&xml_val(logistics_interface,"productCateEN","product")&"','"&xml_val(logistics_interface,"productId","product")&"','"&xml_val(logistics_interface,"producingArea","product")&"','"&xml_val(logistics_interface,"productWeight","product")&"','"&xml_val(logistics_interface,"productPrice","product")&"','"&xml_val(logistics_interface,"ecCompanyId","")&"','"&xml_val(logistics_interface,"whCode","")&"','"&xml_val(logistics_interface,"pickUpAddress","")&"','"&xml_val(logistics_interface,"logisticsOrderId","")&"','"&xml_val(logistics_interface,"orderCode","")&"','"&xml_val(logistics_interface,"tradeId","")&"','"&xml_val(logistics_interface,"mailNo","")&"','"&xml_val(logistics_interface,"packageCode","")&"','"&xml_val(logistics_interface,"Rcountry","")&"','"&xml_val(logistics_interface,"Rprovince","")&"','"&xml_val(logistics_interface,"Rcity","")&"','"&xml_val(logistics_interface,"Raddress","")&"','"&xml_val(logistics_interface,"Rpostcode","")&"','"&xml_val(logistics_interface,"Rname","")&"','"&xml_val(logistics_interface,"Rphone","")&"','"&xml_val(logistics_interface,"Sname","")&"','"&xml_val(logistics_interface,"Sprovince","")&"','"&xml_val(logistics_interface,"Scity","")&"','"&xml_val(logistics_interface,"Saddress","")&"','"&xml_val(logistics_interface,"Sphone","")&"','"&xml_val(logistics_interface,"Spostcode","")&"','"&xml_val(logistics_interface,"insureValue","")&"','"&xml_val(logistics_interface,"insuranceValue","")&"','"&xml_val(logistics_interface,"remark","")&"','"&xml_val(logistics_interface,"channel","")&"','"&xml_val(logistics_interface,"Itotleweight","")&"','"&xml_val(logistics_interface,"Itotlevalue","")&"','"&xml_val(logistics_interface,"totleweight","")&"','"&xml_val(logistics_interface,"hasBattery","")&"','"&xml_val(logistics_interface,"country","")&"','"&xml_val(logistics_interface,"mailKind","")&"','"&xml_val(logistics_interface,"mailClass","")&"','"&xml_val(logistics_interface,"batchNo","")&"','"&xml_val(logistics_interface,"mailType","")&"','"&xml_val(logistics_interface,"faceType","")&"','"&xml_val(logistics_interface,"undeliveryOption","")&"')"

elseif msg_type="LOGISTICS_BATCH_SEND" then

conn.execute "insert into receiver(eventType,eventTime,eventSource,eventTarget,itemNameCN,itemName,itemQuantity,itemcategoryNameCN,itemcategoryName,itemId,producingArea,itemWeight,itemUnitPrice,ecCompanyId,whCode,pickUpAddress,logisticsOrderId,orderCode,tradeId,mailNo,packageCode,packageWeight,ordersInPackage,receiverContact_country,receiverContact_province,receiverContact_city,receiverContact_streetAddress,receiverContact_zipCode,receiverContact_name,receiverContact_phone,sendContact_name,sendContact_province,sendContact_city,sendContact_streetAddress,sendContact_phone,sendContact_zipCode,insureValue,insuranceValue,remark,channel,Itotleweight,Itotlevalue,totleweight,hasBattery,sendContact_country,subOrder_mailType,mailClass,batchNo,SMT_mailType,faceType,subOrder_undeliveryOption) VALUES ('"&xml_val(logistics_interface,"eventType","")&"','"&xml_val(logistics_interface,"eventTime","")&"','"&xml_val(logistics_interface,"eventSource","")&"','"&xml_val(logistics_interface,"eventTarget","")&"','"&xml_val(logistics_interface,"productNameCN","product")&"','"&xml_val(logistics_interface,"productNameEN","product")&"','"&xml_val(logistics_interface,"productQantity","product")&"','"&xml_val(logistics_interface,"productCateCN","product")&"','"&xml_val(logistics_interface,"productCateEN","product")&"','"&xml_val(logistics_interface,"productId","product")&"','"&xml_val(logistics_interface,"producingArea","product")&"','"&xml_val(logistics_interface,"productWeight","product")&"','"&xml_val(logistics_interface,"productPrice","product")&"','"&xml_val(logistics_interface,"ecCompanyId","")&"','"&xml_val(logistics_interface,"whCode","")&"','"&xml_val(logistics_interface,"pickUpAddress","")&"','"&xml_val(logistics_interface,"logisticsOrderId","")&"','"&xml_val(logistics_interface,"orderCode","")&"','"&xml_val(logistics_interface,"tradeId","")&"','"&xml_val(logistics_interface,"mailNo","")&"','"&xml_val(logistics_interface,"packageCode","")&"','"&xml_val(logistics_interface,"packageWeight","")&"','"&xml_val(logistics_interface,"ordersInPackage","")&"','"&xml_val(logistics_interface,"Rcountry","")&"','"&xml_val(logistics_interface,"Rprovince","")&"','"&xml_val(logistics_interface,"Rcity","")&"','"&xml_val(logistics_interface,"Raddress","")&"','"&xml_val(logistics_interface,"Rpostcode","")&"','"&xml_val(logistics_interface,"Rname","")&"','"&xml_val(logistics_interface,"Rphone","")&"','"&xml_val(logistics_interface,"Sname","")&"','"&xml_val(logistics_interface,"Sprovince","")&"','"&xml_val(logistics_interface,"Scity","")&"','"&xml_val(logistics_interface,"Saddress","")&"','"&xml_val(logistics_interface,"Sphone","")&"','"&xml_val(logistics_interface,"Spostcode","")&"','"&xml_val(logistics_interface,"insureValue","")&"','"&xml_val(logistics_interface,"insuranceValue","")&"','"&xml_val(logistics_interface,"remark","")&"','"&xml_val(logistics_interface,"channel","")&"','"&xml_val(logistics_interface,"Itotleweight","")&"','"&xml_val(logistics_interface,"Itotlevalue","")&"','"&xml_val(logistics_interface,"totleweight","")&"','"&xml_val(logistics_interface,"hasBattery","")&"','"&xml_val(logistics_interface,"country","")&"','"&xml_val(logistics_interface,"mailKind","")&"','"&xml_val(logistics_interface,"mailClass","")&"','"&xml_val(logistics_interface,"batchNo","")&"','"&xml_val(logistics_interface,"mailType","")&"','"&xml_val(logistics_interface,"faceType","")&"','"&xml_val(logistics_interface,"undeliveryOption","")&"')"

end if

xmldata="<responses><responseItems><response><success>true</success></response></responseItems></responses>"

response.write xmldata
%>

谢谢

在https的链接中vb使用post提交xml数据
VB调用WebService(直接Post方式)并解析返回的XML

【热门文章】
【热门文章】