|
求C#调用WEBSERVICE上传XML数据的案例
发送的数据是XML,
调用远程的webservice接口
以SOAP方式
站长有例子吗?
以下是对方法给我的接口文档
1、PostESalesCreate
Postesalescreate(postesalescreaterequest astr_request) returns postesalescreateresponse:
上传正常销售交易数据、退货交易数据函数。
软件开发商将每笔销售(退货)数据完结需要调用上传交易Web Service函数,每次只上传一笔交易数据。每一笔交易数据均需包含以下内容:
 Header信息
包括许可证,用户名,密码等等信息
 销售单汇总信息
包括该笔销售的交易日期,交易时间,店铺号,收银机号,交易单据号,总金额,总货品数,付款方式数量(共有几种付款方式)等等信息。
每笔销售数据,只会有一条汇总信息。
 货品信息
包括货品编号,货品单价,货品数量,实际销售交易,等等信息。
每笔销售数据,可有多条货品信息。
 付款方式信息
包括付款方式编号,付款金额(找零后金额)等等信息。
每笔销售数据,可有多条付款方式信息。
返回码解释:
返回码(<responsecode>short</responsecode>)为【0】,表示调用Web Service成功。交易被完整接纳。
返回码(<responsecode>short</responsecode>)为非【0】,表示调用Web Service不成功。不成功信息从(<responsemessage>string</responsemessage>)获取。
函数请求数据格式:
SOAP 1.2
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /TTPOS/sales.asmx HTTP/1.1
Host: 172.31.2.96
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<postesalescreate xmlns="http://tempurl.org">
<astr_request>
<header>
<licensekey>string</licensekey>
<username>string</username>
<password>string</password>
<lang>string</lang>
<pagerecords>int</pagerecords>
<pageno>int</pageno>
<updatecount>int</updatecount>
<messagetype>string</messagetype>
<messageid>string</messageid>
<version>string</version>
</header>
<esalestotal>
<txdate_yyyymmdd>string</txdate_yyyymmdd>
<txtime_hhmmss>string</txtime_hhmmss>
<mallid>string</mallid>
<storecode>string</storecode>
<tillid>string</tillid>
<txdocno>string</txdocno>
<cashier>string</cashier>
<vipcode>string</vipcode>
<salesman>string</salesman>
<netqty>decimal</netqty>
<netamount>decimal</netamount>
<bonusearn>decimal</bonusearn>
<extendparam>string</extendparam>
</esalestotal>
<esalesitems>
<esalesitem>
<lineno>int</lineno>
<itemcode>string</itemcode>
<qty>decimal</qty>
<discountamount>decimal</discountamount>
<netamount>decimal</netamount>
<extendparam>string</extendparam>
<salesitemremark>string</salesitemremark>
</esalesitem>
<esalesitem>
<lineno>int</lineno>
<itemcode>string</itemcode>
<qty>decimal</qty>
<discountamount>decimal</discountamount>
<netamount>decimal</netamount>
<extendparam>string</extendparam>
<salesitemremark>string</salesitemremark>
</esalesitem>
</esalesitems>
<esalestenders>
<esalestender>
<lineno>int</lineno>
<tendercode>string</tendercode>
<payamount>decimal</payamount>
<baseamount>decimal</baseamount>
<excessamount>decimal</excessamount>
<extendparam>string</extendparam>
<remark>string</remark>
</esalestender>
<esalestender>
<lineno>int</lineno>
<tendercode>string</tendercode>
<payamount>decimal</payamount>
<baseamount>decimal</baseamount>
<excessamount>decimal</excessamount>
<extendparam>string</extendparam>
<remark>string</remark>
</esalestender>
</esalestenders>
<esalesdiscounttenders>
<esalesdiscounttender>
<lineno>int</lineno>
<tendercode>string</tendercode>
<payamount>decimal</payamount>
<baseamount>decimal</baseamount>
<excessamount>decimal</excessamount>
<extendparam>string</extendparam>
<remark>string</remark>
</esalesdiscounttender>
<esalesdiscounttender>
<lineno>int</lineno>
<tendercode>string</tendercode>
<payamount>decimal</payamount>
<baseamount>decimal</baseamount>
<excessamount>decimal</excessamount>
<extendparam>string</extendparam>
<remark>string</remark>
</esalesdiscounttender>
</esalesdiscounttenders>
</astr_request>
</postesalescreate>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<postesalescreateResponse xmlns="http://tempurl.org">
<postesalescreateResult>
<header>
<responsecode>short</responsecode>
<responsemessage>string</responsemessage>
<pagerecords>int</pagerecords>
<pageno>int</pageno>
<updatecount>int</updatecount>
<maxrecords>int</maxrecords>
<maxpageno>int</maxpageno>
<messagetype>string</messagetype>
<messageid>string</messageid>
<version>string</version>
</header>
</postesalescreateResult>
</postesalescreateResponse>
</soap12:Body>
</soap12:Envelope>
返回码解释:
返回码(<responsecode>short</responsecode>)为【0】,表示调用Web Service成功。交易被完整接纳。
返回码(<responsecode>short</responsecode>)为非【0】,表示调用Web Service不成功。不成功信息从(<responsemessage>string</responsemessage>)获取。
例子XML数据:
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempurl.org">
<soap:Header/>
<soap:Body>
<tem:postesalescreate>
<!--Optional:-->
<tem:astr_request>
<!--Optional:-->
<tem:header>
<!--Optional:-->
<tem:licensekey/>
<!--Optional:-->
<tem:username/>
<!--Optional:-->
<tem:password/>
<!--Optional:-->
<tem:lang/>
<tem:pagerecords>0</tem:pagerecords>
<tem:pageno>0</tem:pageno>
<tem:updatecount>0</tem:updatecount>
<!--Optional:-->
<tem:messagetype>SALESDATA</tem:messagetype>
<!--Optional:-->
<tem:messageid>332</tem:messageid>
<!--Optional:-->
<tem:version>V332M</tem:version>
</tem:header>
<!--Optional:-->
<tem:esalestotal>
<!--Optional:-->
<tem:txdate_yyyymmdd>20130602</tem:txdate_yyyymmdd>
<!--Optional:-->
<tem:txtime_hhmmss>120000</tem:txtime_hhmmss>
<!--Optional:-->
<tem:mallid>01</tem:mallid>
<!--Optional:-->
<tem:storecode>B12801</tem:storecode>
<!--Optional:-->
<tem:tillid>01</tem:tillid>
<!--Optional:-->
<tem:txdocno>T000000004</tem:txdocno>
<!--Optional:-->
<tem:cashier>001</tem:cashier>
<!--Optional:-->
<tem:vipcode/>
<!--Optional:-->
<tem:salesman>001</tem:salesman>
<tem:netqty>1</tem:netqty>
<tem:netamount>100</tem:netamount>
<!--Optional:-->
<tem:extendparam/>
</tem:esalestotal>
<!--Optional:-->
<tem:esalesitems>
<!--Zero or more repetitions:-->
<tem:esalesitem>
<tem:lineno>1</tem:lineno>
<!--Optional:-->
<tem:itemcode>0128010</tem:itemcode>
<tem:qty>1</tem:qty>
<tem:discountamount>0</tem:discountamount>
<tem:netamount>100</tem:netamount>
<tem:bonusearn>0</tem:bonusearn>
<!--Optional:-->
<tem:extendparam/>
<!--Optional:-->
<tem:salesitemremark/>
</tem:esalesitem>
</tem:esalesitems>
<!--Optional:-->
<tem:esalestenders>
<!--Zero or more repetitions:-->
<tem:esalestender>
<tem:lineno>1</tem:lineno>
<!--Optional:-->
<tem:tendercode>CH</tem:tendercode>
<tem:payamount>100</tem:payamount>
<tem:baseamount>100</tem:baseamount>
<tem:excessamount>0</tem:excessamount>
<!--Optional:-->
<tem:extendparam/>
<!--Optional:-->
<tem:remark/>
</tem:esalestender>
</tem:esalestenders>
</tem:astr_request>
</tem:postesalescreate>
</soap:Body>
</soap:Envelope>
|
|