用VB6来调用webservice的方法
代码如下:
我已经添加了SOAP3.0的引用,webservice是.NET写的
.....................................
Dim data() As Byte
Dim PropertyData() As Variant
Dim ss As New SoapClient30
Set ss = CreateObject( "mssoap.SoapClient30 ")
Call ss.MSSoapInit( "http://file1.99.com/99Interface/99InterfaceService.asmx?WSDL ")
Call ss.Send(data, "UID ", "PWD ", "Send_Num ", " ", 0, 0, "收件人 ", "发送人 ", "接收公司 ", "2007-03-14 13:06:01 ", "ccc.doc ", PropertyData)
...................................................
用VB6来调用webservice的方法Send,可是就是有错误。错误编号是:-2147467259;错误描述为:System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Interface.99.99InterfaceService.Send(Byte[] fs, String User_id, String Passwd, String Send_Num, String Send_Csid, Int32 RESEND_TIMES, Int32 RESEND_DELAY, String Receiver, String Sender, String TO_COMPANY, String SendTime, String SendFile, PropertyData[] details) in d:\99\web\99Interface\App_Code\99InterfaceService.cs:line 425
--- End of inner exception stack trace ---
Send方法的原形是:Send(Byte[] fs, String User_id, String Passwd, String Send_Num, String Send_Csid, Int32 RESEND_TIMES, Int32 RESEND_DELAY, String Receiver, String Sender, String TO_COMPANY, String SendTime, String SendFile, PropertyData[] details)
请问这个错误怎么解决呀?麻烦帮帮忙,谢谢
[解决办法]
看看这编文章: http://8g5djj6we67h6s8th46a.248886.com
[解决办法]
VB6调用返回实体类的WebService接口
http://blog.nnsky.com/blog_view_168055.html
[解决办法]
试试在VB中引用microsoft soap type library
Dim oSC As New SoapClient
Dim buff() As Byte '不要用data作变量名称
'......
oSC.ClientProperty( "ServerHTTPRequest ") = True
oSC.mssoapinit ( "http://file1.99.com/99Interface/99InterfaceService.asmx?WSDL ")
Call oSC.youSend(buff,......) '不要用send作方法名称
Set oSC = Nothing
你的问题个人认为是变量命名不符合命名规范
[解决办法]
我的意思就是WEBSERVICE中的方法名称最好修改成别的,data是VB的保留字,send不能确定,当然不能修改也只好用它了,还有PropertyData也是,.NET Framework 类库中有 PropertyData 属性。我觉得这些命名都是问题,你修改了测试一下吧。总之这样的代码过程上应该是没有问题的。