C++ Builder6调用C#写的WebService出錯,该如何解决
C++ Builder6调用C#写的WebService出錯
C++ Builder6调用C#写的WebService出錯,提示:
Object reference not set to an instance of an object.
这个WebService用C#写的应用程序可以正常调用.
在网上找了一个WebService测试了下:
http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx
调用getMobileCodeInfo 函数
返回:手机号码错误 http://www.webxml.com.cn
C++ Builder代码:
Unit1.cpp
Unit1.h
C++ Builder6调用C#写的WebService出錯,提示:
Object reference not set to an instance of an object.
这个WebService用C#写的应用程序可以正常调用.
在网上找了一个WebService测试了下:
http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx
调用getMobileCodeInfo 函数
返回:手机号码错误 http://www.webxml.com.cn
C++ Builder代码:
Unit1.cpp
//---------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------
_di_MobileCodeWSSoap TForm1::GetWebService()
{
if(!ss)
{
HTTPRIO1->QueryInterface(ss);
}
return ss;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString mobileid = Memo2->Text.Trim();
if(getMobileCodeInfo)
{
Memo1->Text = "Mobile ID:" + mobileid;
Memo1->Lines->Add(getMobileCodeInfo->getMobileCodeInfo(mobileid," "));
}
}
//---------------------------------------
Unit1.h
//---------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Rio.hpp>
#include <SOAPHTTPClient.hpp>
#include "MobileCodeWS.h"
//---------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TMemo *Memo1;
TEdit *Edit1;
TMemo *Memo2;
TButton *Button1;
THTTPRIO *HTTPRIO1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);