请大家帮帮忙(怎么在VC6.0中调用Web Service)
请大家帮帮忙(如何在VC6.0中调用Web Service):
请大家帮帮忙(如何在VC6.0中调用Web Service):
以下是我在.NET 2005中用C#写的Web Service代码:
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://tempuri.org/ ")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
public string HelloWorld() {
return "Hello World ";
}
[WebMethod]
public int Add(int a, int b)
{
int c = a + b;
return c;
}
}
而在VC 6.0中的代码如下:
#include <stdio.h>
#import "msxml4.dll "
using namespace MSXML2;
#import "C:\Program Files\Common Files\MSSOAp\Binaries\mssoap30.dll " \
exclude( "IStream ", "IErrorInfo ", "ISequentialStream ", "_LARGE_INTEGER ", \
"_ULARGE_INTEGER ", "tagSTATSTG ", "_FILETIME ")
using namespace MSSOAPLib30; //你机器得安装SOAP Toolkit3.0 ,1.0时,用using namespace时报错
void Add()
{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service.
Connector.CreateInstance(__uuidof(HttpConnector30));
Connector-> Property[ "EndPointURL "] = "http://localhost/123/Service.asmx ";
Connector-> Connect();
// Begin the message.
//Connector-> Property[ "SoapAction "] = "uri:AddNumbers ";
Connector-> Property[ "SoapAction "] = "http://tempuri.org/Service.HelloWorld ";
Connector-> BeginMessage();
// Create the SoapSerializer object.
Serializer.CreateInstance(__uuidof(SoapSerializer30));
// Connect the serializer object to the input stream of the connector object.
请大家帮帮忙(如何在VC6.0中调用Web Service):
以下是我在.NET 2005中用C#写的Web Service代码:
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://tempuri.org/ ")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
public string HelloWorld() {
return "Hello World ";
}
[WebMethod]
public int Add(int a, int b)
{
int c = a + b;
return c;
}
}
而在VC 6.0中的代码如下:
#include <stdio.h>
#import "msxml4.dll "
using namespace MSXML2;
#import "C:\Program Files\Common Files\MSSOAp\Binaries\mssoap30.dll " \
exclude( "IStream ", "IErrorInfo ", "ISequentialStream ", "_LARGE_INTEGER ", \
"_ULARGE_INTEGER ", "tagSTATSTG ", "_FILETIME ")
using namespace MSSOAPLib30; //你机器得安装SOAP Toolkit3.0 ,1.0时,用using namespace时报错
void Add()
{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service.
Connector.CreateInstance(__uuidof(HttpConnector30));
Connector-> Property[ "EndPointURL "] = "http://localhost/123/Service.asmx ";
Connector-> Connect();
// Begin the message.
//Connector-> Property[ "SoapAction "] = "uri:AddNumbers ";
Connector-> Property[ "SoapAction "] = "http://tempuri.org/Service.HelloWorld ";
Connector-> BeginMessage();
// Create the SoapSerializer object.
Serializer.CreateInstance(__uuidof(SoapSerializer30));
// Connect the serializer object to the input stream of the connector object.