BOOL CCAccessWebService:: CheckBarcodeByService(CString szEndPointURL,CString FunctionID,CString LineID,CString Barcodes,CString &m_retMsg)
{
CoInitialize(NULL);
ISoapConnectorPtr m_connector;
ISoapSerializerPtr m_Serializer;
ISoapReaderPtr m_Reader;
HRESULT hr;
m_retMsg=_T("");
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////1链接服务器
try
{
hr=m_connector.CreateInstance(__uuidof(HttpConnector30));
m_connector->Property["EndPointURL"]=(_bstr_t)(szEndPointURL);//Web调用地址http://192.168.2.252:8019/ServiceCommon.asmx
m_connector->Connect();
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////2发送请求消息
m_connector->Property["SoapAction"]="http://EMacro.com.tw/Command";//namespace+operion "sit"//参照MSDL
m_connector->BeginMessage();
hr=m_Serializer.CreateInstance(__uuidof(SoapSerializer30));
m_Serializer->Init(_variant_t((IUnknown*)m_connector->InputStream));
m_Serializer->StartEnvelope("SOAP","http://schemas.xmlsoap.org/soap/envelope/",(_bstr_t)"UTF-8");//http://schemas.xmlsoap.org/soap/encoding/ (SOAP default encodestyle)
//m_Serializer->StartEnvelope("SOAP","http://schemas.xmlsoap.org/soap/encoding/",(_bstr_t)"UTF-8");//http://schemas.xmlsoap.org/soap/encoding/ (SOAP default encodestyle)
/////////////////////////////////////////////
m_Serializer->StartBody("");
m_Serializer->StartElement("Command","http://EMacro.com.tw/Command","NONE","");//调用"excute"方法
///////////////////////////////////////////
m_Serializer->StartElement("cmd","","NONE","");
m_Serializer->WriteString("16610");
m_Serializer->EndElement();
m_Serializer->StartElement("stationID","","NONE","");
m_Serializer->WriteString("0");
m_Serializer->EndElement();
m_Serializer->StartElement("param","","NONE","");
m_Serializer->WriteString("111111");
m_Serializer->EndElement();
/////////////////////////////////////////
m_Serializer->EndElement();
m_Serializer->EndBody();
m_Serializer->EndEnvelope();
m_connector->EndMessage();
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3读取返回值
hr=m_Reader.CreateInstance(__uuidof(SoapReader30));
VARIANT_BOOL vb=m_Reader->Load(_variant_t((IUnknown*)m_connector->OutputStream),"");
if (vb!=-1)
{
CoUninitialize();
AfxMessageBox(_T("Read Tag Error!"));
return FALSE;
}
if (m_Reader->GetRpcResult())
{
CString m_strResultT=(LPCSTR)(m_Reader->Body->xml);
//AfxMessageBox(m_strResultT);
int m=m_strResultT.Find(_T("<CommandResult>"));
int n=m_strResultT.Find(_T("</CommandResult>"));
int ck=n-(m+15);
m_retMsg=m_strResultT.Mid(m+15,ck);
if (m_retMsg.Find(_T("OK")<0))
{
CoUninitialize();
return FALSE;
}
/*m_retMsg=m_strResultT;
if (m_strResultT.Find(_T("OK")<0))
{
CoUninitialize();
return FALSE;
}*/
}
}
catch (_com_error& e)
{
CoUninitialize();
AfxMessageBox(e.Description());
return FALSE;
}
///////////////////////////////////////////////
return TRUE;
}
为什么c++ 调用webService上传的数据为空?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
悬赏问题
- ¥30 STM32 INMP441无法读取数据
- ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
- ¥15 用visualstudio2022创建vue项目后无法启动
- ¥15 x趋于0时tanx-sinx极限可以拆开算吗
- ¥500 把面具戴到人脸上,请大家贡献智慧
- ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
- ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
- ¥30 c#打开word开启修订并实时显示批注
- ¥15 如何解决ldsc的这条报错/index error
- ¥15 VS2022+WDK驱动开发环境