我现在编一个server端和client端,server端用java实现(用的是tomcat和axis),client端用的是VC++6.0和soap tookit3.0,可是参数为什么传不回来??程序代码如下:服务器端:
public class Calculator
{
  public String Add(String i,String j)
  {
    int  i1=Integer.parseInt(i);
    int  i2= Integer.parseInt(j);
    int  sum = i1+i2;
    String str=String.valueOf(sum);
    return str;
  }
}
保存为Calculator.jws格式,存放在F:\jakarta-tomcat-5.0.28\webapps\axis下;
客户端:
#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 Add()
{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service.
Connector.CreateInstance(__uuidof(HttpConnector30));
Connector->Property["EndPointURL"] = "http://localhost:8080/axis/Calculator.jws?wsdl
Connector->Connect();
// Begin the message.
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("i","","","");
Serializer->WriteString("1");
Serializer->EndElement();
Serializer->StartElement("j","","","");
Serializer->WriteString("2");
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), "");
  
BSTR bstr = NULL; 
_bstr_t s;
// Display the result.
Reader->RpcResult->get_text(&bstr);
s = _bstr_t(bstr);
printf("Answer:%s\n", (LPCSTR)s);    
}
int main()
{
CoInitialize(NULL);
Add();
CoUninitialize();
return 0;
}
先启动tomcat,然后运行客户端程序,结果是:ns1:Client.NoSOAPAction
此时Tomcat显示:
- Unable to find config file.  Creating new servlet engine config file: /WEB-INF
/server-config.wsdd
- Generating fault class
AxisFault
 faultCode: {http://xml.apache.org/axis/}Client.NoSOAPAction
 faultSubcode:
 faultString: no SOAPAction header!为什么没有出现正确的结果:3
??????????????????????????????????????????
望高手指教!!

解决方案 »

  1.   

    我也有同样的问题,我用协议分析器抓包看了,MS的破东西帮我们生成的XML是错误的,MS垃圾害人啊,我现在也不知道怎么解决了。
      

  2.   

    使用soap应该配置config file,主要是指定XMLParser和Transport_http两个动态库的路径,你的问题好像就是config file没有使用
      

  3.   

    看看这篇文章,应该对你有些帮助
    http://www.cnblogs.com/babyblue/archive/2004/04/02/5030.aspx
      

  4.   

    参考:http://www.codeproject.com/soap/VSOAPClient.asp