http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 11510|回复: 3

[咨询站长] 求C#调用WEBSERVICE上传XML数据的案例

[复制链接]
发表于 2015-12-29 10:06:49 | 显示全部楼层 |阅读模式
求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>



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2015-12-29 10:21:05 | 显示全部楼层
WEBSERVICE 为什么要用Http协议,这不是没事找事吗? 直接引用 WEBSERVICE不就行了
 楼主| 发表于 2015-12-29 10:41:30 | 显示全部楼层
站长苏飞 发表于 2015-12-29 10:21
WEBSERVICE 为什么要用Http协议,这不是没事找事吗? 直接引用 WEBSERVICE不就行了

他的接口不支持引用不知道为什么
http://113.105.98.34:9090/TTPOS/sales.asmx
这是他给我的测试地址 我在项目里添加引用找不到
发表于 2015-12-29 11:33:05 | 显示全部楼层
访问不了,受限制,无法引用就找他们,这使用Httphelper,不是能不能实现的问题,而是你后期肯定会有很多的问题。
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-5-8 10:45

© 2014-2021

快速回复 返回顶部 返回列表