我现在服务器端已经建立好了,用的是apache的soap-2_3_1,服务器Tomcat,用java编写的测试程序已经通过,现在需要用VC++编写客户端,有疑问如下:
服务器端:
public class SOAPService 
{
  public String sayHi(String x) 
  {
    return("Hello my friend, " + x + "! Glad to see you!");
  }
}
客户端不知怎样调用,代码如下:
#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;
void hello()
{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service.
Connector.CreateInstance(__uuidof(HttpConnector30));
Connector->Property["EndPointURL"]= "http://localhost:8080/soap/servlet/rpcrouter";//??????????????????????????????????
Connector->Connect();

// Begin the message.
// Connector->Property["SoapAction"]= "urn:SOAPService";//????????????????????????
Connector->BeginMessage();

// Create the SoapSerializer object.
Serializer.CreateInstance(__uuidof(SoapSerializer30));

// Connect the serializer object to the input stream of the connector object.
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));

// Build the SOAP Message.
Serializer->StartEnvelope("","","");
Serializer->StartBody("");
Serializer->StartElement("hello","","","");
Serializer->StartElement("name","","","");
Serializer->WriteString("小张");
Serializer->EndElement();
Serializer->EndElement();
Serializer->EndBody();
Serializer->EndEnvelope();

// Send the message to the XML Web service.
Connector->EndMessage();      

// Read the response.
Reader.CreateInstance(__uuidof(SoapReader30));

// Connect the reader to the output stream of the connector object.
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");

// Display the result.
printf("Answer: %s\n", (const char*)Reader->RpcResult->text);
    
}int main()
{
CoInitialize(NULL);
hello();
CoUninitialize();
return 0;
}
运行结果:Answer: SOAP-ENV:Server.BadTargetObjectURI