服务器无法处理请求。 --> 值不能为空。参数名: s

「已注销」 2006-12-12 04:22:37

用vc调用.net写的一个web service,下面是程序,然后是得到的返回信息

CString Test()
{
HRESULT hr;

ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service.
hr = Connector.CreateInstance(__uuidof(HttpConnector30));
// Connector->Property["EndPointURL"] = L"http://localhost/axis/Test.jws";
Connector->Property["EndPointURL"] = L"http://10.10.0.3/DataServices/DataServices.asmx";

hr = Connector->Connect();

// Begin the message.

Connector->Property["SoapAction"] = L"http://tempuri.org/QueryTable";
hr = Connector->BeginMessage();

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

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

// Build the SOAP Message.

hr = Serializer->StartEnvelope("", "", "");
// Serializer->SoapNamespace(L"xsi", L"http://www.w3.org/2001/XMLSchema-instance");
// Serializer->SoapNamespace(L"xsd",L"http://www.w3.org/2001/XMLSchema");

hr = Serializer->StartBody(L"");

hr = Serializer->StartElement(L"QueryTable","","","");

hr = Serializer->StartElement(L"strXML","","","");



hr = Serializer->WriteString(L"<?xml version='1.0' ?><ROOT>ttt</ROOT>");
hr = Serializer->EndElement();


hr = Serializer->EndElement();
hr = Serializer->EndBody();
hr = Serializer->EndEnvelope();


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

// Read the response.
hr = 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.
CString strRet = (const char*)Reader->Dom->xml;
_cprintf("Answer: %s\n", strRet);

// CString strRet = (const char*)Reader->RpcResult->text;
// _cprintf("Answer2: %s\n", strRet);

return strRet;
}

// 返回的消息
Answer: <?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XM
LSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>服务器无法处理请求。 --> 值不能为空。
参数名: s</faultstring>
<detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>

由于服务器端是其他公司开发的,不知道是我调用方式的问题,还是服务器端自己执行出错了,那个提示究竟是什么意思啊
...全文
1168 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenjunhui 2006-12-21
  • 打赏
  • 举报
回复
俺就是来顶滴
「已注销」 2006-12-18
  • 打赏
  • 举报
回复
用ie访问服务器端时给出的格式:


下面是一个 SOAP 请求和响应示例。所显示的占位符需要由实际值替换。

POST /DataWebServices/DataServices.asmx HTTP/1.1
Host: 100.4.22.114
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.myservice.com/Rpc"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:types="http://tempuri.org/encodedTypes" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<q1:QueryTableState xmlns:q1="http://www.myservice.com/SU">
<strXML xsi:type="xsd:string">string</strXML>
</q1:QueryTableState>
</soap:Body>
</soap:Envelope>


HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:types="http://tempuri.org/encodedTypes" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<q2:QueryTableStateResponse xmlns:q2="http://www.myservice.com/SU">
<QueryTableStateResult xsi:type="xsd:string">string</QueryTableStateResult>
</q2:QueryTableStateResponse>
</soap:Body>
</soap:Envelope>

「已注销」 2006-12-18
  • 打赏
  • 举报
回复
上面的问题解决了,是服务器端名字空间指定的不对,下面的java代码调用可以成功,但是vc的还是有问题。

String endpoint="http://localhost/DataWebServices/DataServices.asmx";
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://www.myservice.com/SU","QueryTableState"));
call.addParameter("strXML",org.apache.axis.encoding.XMLType.XSD_DATE,javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_STRING);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://www.myservice.com/Rpc");
String strResult = (String)call.invoke(new Object[]{strXML});
System.out.println( "result is " + strResult.toString() + ".");


感觉就是下面这两行java代码不知道vc里怎么写
call.setOperationName(new QName("http://www.myservice.com/SU","QueryTableState"));
。。。
call.setSOAPActionURI("http://www.myservice.com/Rpc");
midymidy 2006-12-15
  • 打赏
  • 举报
回复
有道理
jamzh 2006-12-14
  • 打赏
  • 举报
回复
好像VC中的数据结构与.net中的长度不一致,你检查看看是否是有不匹配的
liujia_0421 2006-12-14
  • 打赏
  • 举报
回复
这个问题有点麻烦..
chenjunhui 2006-12-13
  • 打赏
  • 举报
回复
顶是硬道理

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧