C#连JAVA的有安全信息头(soap)webservice问题 ?100分webservice带消息头的请求写法

tys101582 2012-08-11 09:11:01
最近对方提供了一个接口文档给我,没链过这样的有安全信息头的服务,请高手帮忙指点一下怎么写,好吗?

接口说明如下:
按SGIP协议进行通讯;

1.3 接口规范
测试接口地址配置文件
http://192.168.0.168/services/SMSSendTask?wsdl

信息进行安全认证:
webservice的头域认证,head里面包括如下几个字段
名称 类型 备注
sequence int 范围从0到Int的上限,然后尾追回0,周而复始。Sequence每次发送后必须自增,如果系统发现当前已发送的sequence大于请求的sequence,系统认为此媒体信息非法(只有当SP的安全认证为高时才验证sequence)
spid String 短信平台分配的SPID
timestamp String 格式yyyyMMddHHmmss(14位,24小时制),时间戳必须是当前时间的则系统认为媒体信息非法
key String 格式 sequence+spid+password+ timestamp的MD5加密字符串。这里的password也是平台分配的密钥
mode int 默认填写0
info String 暂时为空

1.3.1 短信下行接口
函数功能
该接口用于SP提交短信下发任务。
函数说明
MediaResultBean[] sendMediaTask(ExtMediaTaskBean[] extMediaTasks)
参数说明:

参数 如何理解
extMediaTasks 媒体消息数组




MediaResultBean说明:
参数 如何理解 类型
index 为0的时候才是处理成功,其他都是失败 int
mediaTaskID 获取状态报告的ID,为0时没有是不需要状态报告 String
resultNo 只有返回10000是才是正确,其他的都是失败 String
ExtMediaTaskBean说明:
参数 如何理解 类型 必填
sendNo 发送方(默认为114) String Y
receiverInfo 接收方 String N
content 发送内容 String Y
subject 主题 String Y
staffNo 提交人工号 String N
sendTime 发送时间 格式为:(yyyy-MM-dd HH:mm:ss) Date N
priority 优先级
1008001:低
1008002:中
1008003:高 String Y
spId SPID String Y
接口调用说明
接口调用时,会对SP的信息进行安全认证。



我在C#中引用了这个服务,但是不知在方法前如何加这个信息安全头head,请高手指点,对方也不提供DEMO,唉。

void fun1()
{
sms_sp.Web_SmsSP.SMSSendTask smsst = new sms_sp.Web_SmsSP.SMSSendTask();

sms_sp.Web_SmsSP.ExtMediaTaskBean[] emtb_arr = new sms_sp.Web_SmsSP.ExtMediaTaskBean[3];
emtb_arr[0] = new sms_sp.Web_SmsSP.ExtMediaTaskBean();
//emtb_arr[0].sendTime = ....;
//....


emtb_arr[1] = new sms_sp.Web_SmsSP.ExtMediaTaskBean();
//emtb_arr[1].sendTime = ....;
//....;

emtb_arr[2] = new sms_sp.Web_SmsSP.ExtMediaTaskBean();
//emtb_arr[2].sendTime = ....;
//....;

smsst.sendMediaTask(emtb_arr);

}


分不够在加!
...全文
1230 36 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
36 条回复
切换为时间正序
请发表友善的回复…
发表回复
史斌斌 2013-09-23
  • 打赏
  • 举报
回复
引用 35 楼 myodecade 的回复:
楼主问题解决没,是不是在做一个短信接口,遇到了同样的问题,想请教您一下....
同志们有解决的吗?给个回复呗,出现的相同的问题,网上能找到的都不好用呀
myodecade 2013-09-02
  • 打赏
  • 举报
回复
楼主问题解决没,是不是在做一个短信接口,遇到了同样的问题,想请教您一下....
ypeuee 2012-11-13
  • 打赏
  • 举报
回复
1.首先要自定义SoapHeader,须继承System.Web.Services.Protocols.SoapHeader 。 using System; using System.Collections.Generic; using System.Web; /// <summary> ///自定义的SoapHeader /// </summary> public class MySoapHeader : System.Web.Services.Protocols.SoapHeader { private string userName=string.Empty; private string passWord=string.Empty; /// <summary> /// 构造函数 /// </summary> public MySoapHeader() { } /// <summary> /// 构造函数 /// </summary> /// <param name="userName">用户名</param> /// <param name="passWord">密码</param> public MySoapHeader(string userName, string passWord) { this.userName = userName; this.passWord = passWord; } /// <summary> /// 获取或设置用户用户名 /// </summary> public string UserName { get { return userName; } set { userName = value; } } /// <summary> /// 获取或设置用户密码 /// </summary> public string PassWord { get { return passWord; } set { passWord = value; } } } 2.添加WebService,并编写相应代码。 using System; using System.Collections.Generic; using System.Web; using System.Web.Services; /// <summary> ///WebService 的摘要说明 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class WebService : System.Web.Services.WebService { //声明Soap头实例 public MySoapHeader myHeader=new MySoapHeader(); [System.Web.Services.Protocols.SoapHeader("myHeader")] [WebMethod] public string HelloWord() { //可以通过存储在数据库中的用户与密码来验证 if (myHeader.UserName.Equals("houlei")&myHeader.PassWord.Equals("houlei")) { return "调用服务成功!"; } else { return "对不起,您没有权限调用此服务!"; } } } 3.客户端调用,分别使用不设置SoapHeader与设置SoapHeader。 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace App { class Program { static void Main(string[] args) { localhost.WebService service = new localhost.WebService(); //没有设置SoapHeader的服务调用 Console.WriteLine("没有设置SoapHeader:" + service.HelloWord()); Console.WriteLine(); //将用户名与密码存入SoapHeader; localhost.MySoapHeader header = new localhost.MySoapHeader(); header.UserName = "houlei"; header.PassWord = "houlei"; service.MySoapHeaderValue = header; //设置SoapHeader的服务调用 Console.WriteLine("设置SoapHeader:" + service.HelloWord()); Console.Read(); } } } 4.运行应用程序,查看运行结果。 1.首先要自定义SoapHeader,须继承System.Web.Services.Protocols.SoapHeader 。 using System; using System.Collections.Generic; using System.Web; /// <summary> ///自定义的SoapHeader /// </summary> public class MySoapHeader : System.Web.Services.Protocols.SoapHeader { private string userName=string.Empty; private string passWord=string.Empty; /// <summary> /// 构造函数 /// </summary> public MySoapHeader() { } /// <summary> /// 构造函数 /// </summary> /// <param name="userName">用户名</param> /// <param name="passWord">密码</param> public MySoapHeader(string userName, string passWord) { this.userName = userName; this.passWord = passWord; } /// <summary> /// 获取或设置用户用户名 /// </summary> public string UserName { get { return userName; } set { userName = value; } } /// <summary> /// 获取或设置用户密码 /// </summary> public string PassWord { get { return passWord; } set { passWord = value; } } } 2.添加WebService,并编写相应代码。 using System; using System.Collections.Generic; using System.Web; using System.Web.Services; /// <summary> ///WebService 的摘要说明 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class WebService : System.Web.Services.WebService { //声明Soap头实例 public MySoapHeader myHeader=new MySoapHeader(); [System.Web.Services.Protocols.SoapHeader("myHeader")] [WebMethod] public string HelloWord() { //可以通过存储在数据库中的用户与密码来验证 if (myHeader.UserName.Equals("houlei")&myHeader.PassWord.Equals("houlei")) { return "调用服务成功!"; } else { return "对不起,您没有权限调用此服务!"; } } } 3.客户端调用,分别使用不设置SoapHeader与设置SoapHeader。 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace App { class Program { static void Main(string[] args) { localhost.WebService service = new localhost.WebService(); //没有设置SoapHeader的服务调用 Console.WriteLine("没有设置SoapHeader:" + service.HelloWord()); Console.WriteLine(); //将用户名与密码存入SoapHeader; localhost.MySoapHeader header = new localhost.MySoapHeader(); header.UserName = "houlei"; header.PassWord = "houlei"; service.MySoapHeaderValue = header; //设置SoapHeader的服务调用 Console.WriteLine("设置SoapHeader:" + service.HelloWord()); Console.Read(); } } } 4.运行应用程序,查看运行结果。
Jenopob 2012-10-23
  • 打赏
  • 举报
回复
现在这个解决了伐,我也碰到类似问题
tys101582 2012-08-24
  • 打赏
  • 举报
回复
主要是我还不会JAVA
Tod707070 2012-08-23
  • 打赏
  • 举报
回复
你用相同的框架加soapheader很容易,但是框架不同的话即便都是java写的都不容易实现调用,更何况c#.何苦为难自己呢。还是用我的方法吧。
Tod707070 2012-08-23
  • 打赏
  • 举报
回复
我说楼主,那些c#加soapheader的资料不是没有看过。但是我看都没有几个成功的。虽说webservice本来是标准化的,可是实现起来框架很多,各框架之间都不一定共通,更何况你还要跨语言。人家也不是不会c#,只是c#根本没有办法直接调用哪些java的webservice框架。
你要是会java,把对方给你的demo改一下,打包成命令行的jar,或者改成去掉soapheader的webservice服务,再用c#的process类去调用。
我以前遇到的一个项目就是c#调用xfire的webservice,对方也是soapheader验证,我拿着对方给的java的demo改造了一下,写了个jar程序,这个jar完成这么几个事情:
(1)接受c#的process类调用,并加soapheader包发server请求服务.
(2)从server接收返回,以标准输出方式返回给c#结果。
tys101582 2012-08-21
  • 打赏
  • 举报
回复
对方,这个服务是是 java 平台实现的,MyCustomSoapHeaderValue点不出来,有高手连过C#和JAVA对接的不?
tys101582 2012-08-21
  • 打赏
  • 举报
回复
这个是他们提供的JAVA的例子,没有C#的,估计他们不会C#,没给提供。

package com.webservice;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.namespace.QName;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties.ProxyProperties;

import com.huawei.sports.utilities.MD5Tool;
import com.huawei.sports.webservice.ExtMediaTaskBean;
import com.huawei.sports.webservice.MediaBean;
import com.huawei.sports.webservice.MediaResultBean;

public class ClientTest
{

/**
* @param args
* @throws Exception
*/
public static void main11(String[] args) throws Exception
{
System.out.println(new SimpleDateFormat("MMdd").format(new Date()));
}

public static void main(String[] args) throws Exception
{
String url = "http://61.156.3.152:9090/services/SMSSendTask";
//String url = "http://localhost:9090/services/SMSSendTask";
String namespace = "http://webservice.sports.huawei.com";

String operateName = "sendMediaTask";
//String operateName = "getMediasBean";

ProxyProperties proxyProperties = new ProxyProperties();
proxyProperties.setProxyName("10.237.0.203");
proxyProperties.setProxyPort(808);

RPCServiceClient client = new RPCServiceClient();
client.addHeader(createHeaderOMElement());
/******************----***********/
//OMFactory fac = OMAbstractFactory.getOMFactory();
//QName qname = new QName(namespace, "upload");
//OMElement data = fac.createOMElement(qname);
/*****************-----***********/
//client.sendReceive(data);
Options option = client.getOptions();
EndpointReference erf = new EndpointReference(url);
option.setTo(erf);
option.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
option.setProperty(Constants.Configuration.ENABLE_MTOM,
Constants.VALUE_TRUE);
option.setTransportInProtocol(Constants.TRANSPORT_HTTP);
option.setProperty(HTTPConstants.PROXY, proxyProperties);
option.setProperty(HTTPConstants.HTTP_PROTOCOL_VERSION,
HTTPConstants.HEADER_PROTOCOL_10);
client.setOptions(option);
QName name = new QName(namespace, "sendMediaTask");
//QName name = new QName(namespace, "getMediasBean");
ExtMediaTaskBean ob1 = new ExtMediaTaskBean();
ob1.setSpId("SP1141000155183");
ob1.setSubject("SPTEST");
ob1.setSendNo("10655116114");
ob1.setReceiverInfo("13256675150");
ob1.setContent("123SDA");
ob1.setAccessoryPath("20120723183001-SP1141000155343.zip");
ob1.setSendTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2012-05-25 13:00:00"));
//ob1.setSendTime(new Date("2011-12-24"));
ExtMediaTaskBean ob2 = new ExtMediaTaskBean();
ExtMediaTaskBean[] ob = new ExtMediaTaskBean[] { ob1 };
//Object [] object = new Object[]{"SP1141000155243","2011-11-01 00:00:00","2012-05-01 00:00:00"};
Object[] object = new Object[] { ob };
//Class [] returnTypes = new Class[] { MediaBean[].class };
Class[] returnTypes = new Class[] { MediaResultBean[].class };
Object[] response = client.invokeBlocking(name, object, returnTypes);
MediaBean[] p = (MediaBean[]) response[0];
for (int i = 0; i < p.length; i++)
{
System.out.println(p[i].getContent() + "--" + p[i].getSendno());
}
}

public static OMElement createHeaderOMElement()
{
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace SecurityElementNamespace = factory.createOMNamespace("http://handler.com",
"wsse");
OMElement authenticationOM = factory.createOMElement("Authentication",
SecurityElementNamespace);
OMElement sequence = factory.createOMElement("sequence",
SecurityElementNamespace);
OMElement spid = factory.createOMElement("spid",
SecurityElementNamespace);
OMElement timestamp = factory.createOMElement("timestamp",
SecurityElementNamespace);
OMElement key = factory.createOMElement("key", SecurityElementNamespace);
sequence.setText("001");
spid.setText("SP1141000155183");
timestamp.setText("20111222010101");
key.setText(MD5Tool.generateMD5String("001" + "SP1141000155183"
+ "116114" + "20111222010101"));
authenticationOM.addChild(sequence);
authenticationOM.addChild(spid);
authenticationOM.addChild(timestamp);
authenticationOM.addChild(key);
return authenticationOM;
}

}


tys101582 2012-08-21
  • 打赏
  • 举报
回复
smsst.Header.User 这个header是点不出来的,没有的


<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://webservice.sports.huawei.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax21="http://webservice.sports.huawei.com/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://webservice.sports.huawei.com">
<wsdl:documentation>SMSSendTask</wsdl:documentation>
- <wsdl:types>
- <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://webservice.sports.huawei.com/xsd">
- <xs:complexType name="MediaBean">
- <xs:sequence>
<xs:element minOccurs="0" name="accepttime" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="content" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="id" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="receiverinfo" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="sendno" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
- <xs:complexType name="ExtMediaTaskBean">
- <xs:sequence>
<xs:element minOccurs="0" name="accessoryPath" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="content" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="priority" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="receiverInfo" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="sendNo" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="sendTime" nillable="true" type="xs:dateTime" />
<xs:element minOccurs="0" name="serviceId" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="spId" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="staffNo" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="subject" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
- <xs:complexType name="MediaResultBean">
- <xs:sequence>
<xs:element minOccurs="0" name="index" type="xs:int" />
<xs:element minOccurs="0" name="mediaTaskID" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="resultNo" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
- <xs:schema xmlns:ax22="http://webservice.sports.huawei.com/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://webservice.sports.huawei.com">
<xs:import namespace="http://webservice.sports.huawei.com/xsd" />
- <xs:element name="getMediasBean">
- <xs:complexType>
- <xs:sequence>
<xs:element minOccurs="0" name="spid" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="beginDate" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="endDate" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getMediasBeanResponse">
- <xs:complexType>
- <xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax22:MediaBean" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="sendMediaTask">
- <xs:complexType>
- <xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="extMediaTasks" nillable="true" type="ax22:ExtMediaTaskBean" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="sendMediaTaskResponse">
- <xs:complexType>
- <xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax22:MediaResultBean" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
- <wsdl:message name="getMediasBeanRequest">
<wsdl:part name="parameters" element="ns:getMediasBean" />
</wsdl:message>
- <wsdl:message name="getMediasBeanResponse">
<wsdl:part name="parameters" element="ns:getMediasBeanResponse" />
</wsdl:message>
- <wsdl:message name="sendMediaTaskRequest">
<wsdl:part name="parameters" element="ns:sendMediaTask" />
</wsdl:message>
- <wsdl:message name="sendMediaTaskResponse">
<wsdl:part name="parameters" element="ns:sendMediaTaskResponse" />
</wsdl:message>
- <wsdl:portType name="SMSSendTaskPortType">
- <wsdl:operation name="getMediasBean">
<wsdl:input message="ns:getMediasBeanRequest" wsaw:Action="urn:getMediasBean" />
<wsdl:output message="ns:getMediasBeanResponse" wsaw:Action="urn:getMediasBeanResponse" />
</wsdl:operation>
- <wsdl:operation name="sendMediaTask">
<wsdl:input message="ns:sendMediaTaskRequest" wsaw:Action="urn:sendMediaTask" />
<wsdl:output message="ns:sendMediaTaskResponse" wsaw:Action="urn:sendMediaTaskResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="SMSSendTaskSoap11Binding" type="ns:SMSSendTaskPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="getMediasBean">
<soap:operation soapAction="urn:getMediasBean" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="sendMediaTask">
<soap:operation soapAction="urn:sendMediaTask" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="SMSSendTaskSoap12Binding" type="ns:SMSSendTaskPortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="getMediasBean">
<soap12:operation soapAction="urn:getMediasBean" style="document" />
- <wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="sendMediaTask">
<soap12:operation soapAction="urn:sendMediaTask" style="document" />
- <wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="SMSSendTaskHttpBinding" type="ns:SMSSendTaskPortType">
<http:binding verb="POST" />
- <wsdl:operation name="getMediasBean">
<http:operation location="SMSSendTask/getMediasBean" />
- <wsdl:input>
<mime:content type="text/xml" part="getMediasBean" />
</wsdl:input>
- <wsdl:output>
<mime:content type="text/xml" part="getMediasBean" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="sendMediaTask">
<http:operation location="SMSSendTask/sendMediaTask" />
- <wsdl:input>
<mime:content type="text/xml" part="sendMediaTask" />
</wsdl:input>
- <wsdl:output>
<mime:content type="text/xml" part="sendMediaTask" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="SMSSendTask">
- <wsdl:port name="SMSSendTaskHttpSoap11Endpoint" binding="ns:SMSSendTaskSoap11Binding">
<soap:address location="http://134.32.32.152:9090/services/SMSSendTask.SMSSendTaskHttpSoap11Endpoint/" />
</wsdl:port>
- <wsdl:port name="SMSSendTaskHttpSoap12Endpoint" binding="ns:SMSSendTaskSoap12Binding">
<soap12:address location="http://134.32.32.152:9090/services/SMSSendTask.SMSSendTaskHttpSoap12Endpoint/" />
</wsdl:port>
- <wsdl:port name="SMSSendTaskHttpEndpoint" binding="ns:SMSSendTaskHttpBinding">
<http:address location="http://134.32.32.152:9090/services/SMSSendTask.SMSSendTaskHttpEndpoint/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
机器人 2012-08-20
  • 打赏
  • 举报
回复
smsst.Header.User ? 自己点点看就知道了。或者看看 Header 的定义
bwangel 2012-08-20
  • 打赏
  • 举报
回复
既然是webservice,那必然是符合工业标准的,也就是不需要你作什么特例编程的。
感觉不应该如LZ所说的如此的复杂。
tys101582 2012-08-20
  • 打赏
  • 举报
回复
[Quote=引用 23 楼 的回复:]
能找到这个类定义不? sms_sp.Web_SmsSP.SMSSendTask

里面有没有header属性?

或者你把 wsdl 贴出来
[/Quote]

这个sms_sp.Web_SmsSP.SMSSendTask 有
q89584161 2012-08-20
  • 打赏
  • 举报
回复
信息进行安全认证:
webservice的头域认证,head里面包括如下几个字段
名称 类型 备注
sequence int 范围从0到Int的上限,然后尾追回0,周而复始。Sequence每次发送后必须自增,如果系统发现当前已发送的sequence大于请求的sequence,系统认为此媒体信息非法(只有当SP的安全认证为高时才验证sequence)
spid String 短信平台分配的SPID
timestamp String 格式yyyyMMddHHmmss(14位,24小时制),时间戳必须是当前时间的则系统认为媒体信息非法
key String 格式 sequence+spid+password+ timestamp的MD5加密字符串。这里的password也是平台分配的密钥
mode int 默认填写0
info String 暂时为空


要把这个参数传过去..
机器人 2012-08-20
  • 打赏
  • 举报
回复
能找到这个类定义不? sms_sp.Web_SmsSP.SMSSendTask

里面有没有header属性?

或者你把 wsdl 贴出来
Tod707070 2012-08-20
  • 打赏
  • 举报
回复
[Quote=引用 21 楼 的回复:]

我引用了,但是类里没有关于这个header的,对方是JAVA写的一个webservices
[/Quote]
还是用我的方法吧,java写个webservices的客户端,把soapheader包装一下,用c#命令行调用就是了。我就是这么做的,超级稳定。现在java好多webservices太多框架了,搞不懂呀。
tys101582 2012-08-20
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 的回复:]

不过记得大致的思路

在消息头上增加了username 和 password 两个参数
楼主可以试试
[/Quote]

我没用过这个头,怎么加呢,是用什么方法,怎么写呢?
tys101582 2012-08-20
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

用WCF吧,WCF控制消息头很容易,连接webservice也没问题,而你说的c# webservice我没用过,不知道是否方便。
[/Quote]

我这是2005,没WCF吧?
tys101582 2012-08-20
  • 打赏
  • 举报
回复
我这个SoapHeader点不出来,里面没这个方法呢?
lanweiqiang 2012-08-20
  • 打赏
  • 举报
回复
不过记得大致的思路

在消息头上增加了username 和 password 两个参数
楼主可以试试
加载更多回复(15)

111,096

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧