发表于:2005-03-10 13:51:00
楼主
我用VC(ATL)实现OPC XML DA,
__interface ISimpleSoapAppService
{
[id(1)] HRESULT GetStatus([in] BSTR LocaleID, [in] BSTR ClientRequestHandle, [out] ServerStatus* Status, [out,retval] ReplyBase* GetStatusResult);
};
[ soap_method ]
HRESULT GetStatus(/*[in]*/ BSTR LocaleID, /*[in]*/ BSTR ClientRequestHandle, /*[out]*/ ServerStatus* Status, /*[out,retval]*/ ReplyBase* GetStatusResult)
{
......
return S_OK;
}
但是我发现OPC XML的规范好像不是标准的SOAP规范,我看过的许多SOAP都没有属性的概念.如下:
<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/XMLSchema" >
<soap:Body>
<GetStatus LocaleID="de-AT"
xmlns="http://opcfoundation.org/webservices/XMLDA/1.0/" />
</soap:Body>
</soap:Envelope>
其中LocaleID是以XML节点属性的方式出现,这样的话我以上VC设计中的接口永远无法得到LocaleID的值,如果改成这样就可以
<?xml version="1.0" encoding="utf-8"?>
<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/XMLSchema" >
<soap:Body>
<GetStatus xmlns="http://opcfoundation.org/webservices/XMLDA/1.0/" >
<LocaleID>de-AT</LocaleID>
</GetStatus>
</soap:Body>
</soap:Envelope>
还有,按OPC XML的例子中,其返回的XML如下:
<GetStatusResult RcvTime="2003-05-26T20:17:42.4781250-07:00"
ReplyTime="2003-05-26T20:17:42.5781250-07:00"
RevisedLocaleID="de" ServerState="running" />
可是我的程序返回的却是:
<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/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<snp:GetStatus xmlns:snp="urn:SimpleSoapAppService">
<GetStatusResult>
<RcvTime>38406.732187499998</RcvTime>
<ReplyTime>38406.732187499998</ReplyTime>
<ClientRequestHandle>ClientRequestHandle Demo</ClientRequestHandle>
<RevisedLocaleID>RevisedLocaleID Demo</RevisedLocaleID>
<ServerState>running</ServerState>
</GetStatusResult>
<Status>
<StatusInfo>StatusInfo Demo</StatusInfo>
<VendorInfo>VendorInfo</VendorInfo>
<SupportedLocaleIDs>SupportedLocaleIDs</SupportedLocaleIDs>
<SupportedInterfaceVersions>XML_DA_Version_1_0</SupportedInterfaceVersions>
<StartTime>38406.732187499998</StartTime>
<ProductVersion>ProductVersion Demo</ProductVersion>
</Status>
</snp:GetStatus>
她就说例子中有此是作为节点属性出现,有些是作为节点文本出现,可我的返回值却全部是作为节点文本.
我是这样定义ServerStatus的
struct ServerStatus
{
BSTR StatusInfo;
BSTR VendorInfo;
BSTR SupportedLocaleIDs;
interfaceVersion SupportedInterfaceVersions;
DATE StartTime;
BSTR ProductVersion;
}
请问我错在哪里,该如何改!请高手指点一二.