net怎么.net 调用sap rfc接口API接口

问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
1.当我向服务器提交数据是,返回true,2.但是刷新数据库,发现数据插入没有成功,为空。
asp.api 代码
&!--#include file="conn.asp" --&&!--#include file="md5_utf8.asp" --&&%Response.Charset = "UTF-8"Server.ScriptTimeOut=500000logistics_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&"&","")
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&"&","")
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","")&"')"
xmldata="&responses&&responseItems&&response&&success&true&/success&&/response&&/responseItems&&/responses&"
response.write xmldata %&
同步到新浪微博
分享到微博?
Hi,欢迎来到 SegmentFault 技术社区!⊙▽⊙ 在这里,你可以提出编程相关的疑惑,关注感兴趣的问题,对认可的回答投赞同票;大家会帮你解决编程的问题,和你探讨技术更新,为你的回答投上赞同票。
明天提醒我
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
我要该,理由是:
扫扫下载 App(window.slotbydup=window.slotbydup || []).push({
id: '3284507',
container: s,
size: '0,0',
display: 'inlay-fix'
jQuery跨域调用Asp.Net Web API 实现教程及代码
Asp.Net Web API是一个轻量级的Web服务,当Web API和Web程序不是部署在同一域的时候,要使用jQuery来实现调用API的接口就存在跨域的问题。下面介绍两种方式来解决jQuery调用API跨域的问题。
IIS:IIS8.0
VS:VS2013
.Net Framework:4.5
第一种方法
微软提供了一种在服务端的跨域的方法,详细步骤可以参考下面链接:
http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api
总结一下就是下面的几个步骤:
1、 使用NuGet命令Install-Package Microsoft.AspNet.WebApi.Cors 安装依赖项;
2、 WebApiConfig类修改如下,该类在App_Start目录下。
public static class WebApiConfig
public static void Register(HttpConfiguration config)
config.EnableCors();
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: &DefaultApi&,
routeTemplate: &api/{controller}/{id}&,
defaults: new { id = RouteParameter.Optional }
3、在Api的Controller上添加特性,如下:
[EnableCors(origins:&*&,headers:&*&,methods:&*&)]
[RoutePrefix(&api/pro&)]
public class ProjectFilesApiController : ApiController
origins: 访问API的客户端的地址,比如http://localhost:8001 ,如有多个可以用逗号隔开,设置为*号表示任何客户端都可以访问。
第二种方法
第二种方法相对比较简单,只是修改下配置文件即可。
配置文件代码如下:
&system.webServer&
&httpProtocol&
&customHeaders&
&add name=&Access-Control-Allow-Origin& value=&*& /&
&add name=&Access-Control-Allow-Headers& value=&Content-Type& /&
&add name=&Access-Control-Allow-Methods& value=&GET, POST, PUT, DELETE, OPTIONS& /&
&/customHeaders&
&/httpProtocol&
&handlers&
&remove name=&ExtensionlessUrlHandler-Integrated-4.0& /&
&!--&remove name=&OPTIONSVerbHandler& /&--&
&remove name=&TRACEVerbHandler& /&
&add name=&ExtensionlessUrlHandler-Integrated-4.0& path=&*.& verb=&*& type=&System.Web.Handlers.TransferRequestHandler& preCondition=&integratedMode,runtimeVersionv4.0& /&
&/handlers&
&directoryBrowse enabled=&true& /&
&/system.webServer&
上面的两种方法都可以达到跨域的效果,但是这两种方法都只支持IE10+,Chrome下没有问题。想要支持IE10以下的浏览器,需要在调用之前设置下jQuery的跨域属性,代码如下:
function corsTest() {
//设置jQuery支持跨域
jQuery.support.cors =
url: &http://localhost:8010/api/pro/empty&,
type: &POST&,
dataType: &json&,
success: function (data) {
alert(data);
error: function (a) {
标签(Tag):
------分隔线----------------------------
------分隔线----------------------------

我要回帖

更多关于 asp.net mvc 调用接口 的文章

 

随机推荐