我现在编一个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
??????????????????????????????????????????
望高手指教!!
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
??????????????????????????????????????????
望高手指教!!
解决方案 »
- 散个分,攒点人品
- 多个工程使用同一个预编译宏
- WINDOWS在文件重命名时不能录入带有/ \ : * ? " < > ¦ 字符,它是怎么现实的?如想在我的LISTVIEW控件中也不能录入带有上述字符,怎么做?
- 简单问题,求救,200高分相送!
- 关于窗口顺序,(Z-ORDER),窗口顺序被改变时会接收到什么消息?
- 如何将文本框中的字符串更新到CEditView中?
- 问几个关于CTreeCtrl类的问题
- 如何在所有窗口的最上层绘图,并确保图形不被覆盖?
- 请教高手!
- 为什么我使用比StretchBlt从内存中讲位图复制到屏幕上后出现了位图变质?
- VC中用soap!!!
- 请教用SoapToolkit20怎么和https进行soap通讯?
http://www.cnblogs.com/babyblue/archive/2004/04/02/5030.aspx