In the cpp file:. Void CMyTreeViewDlg :: AddMajor () {ISoapSerializerPtr Serializer; ISoapReaderPtr Reader; ISoapConnectorPtr Connector; // Connect to the service Connector.CreateInstance (__ uuidof (HttpConnector30)); Connector-> Property [ "EndPointURL"] = " Http://localhost/ws_elearning/necservices/wsjiaowu/additionalws.asmx? WSDL "; connector-> connect ();
// xml version = "1.0" encoding = "UTF-8"?> //
// begin the message. // connector-> Property ["soapaction"] = "URI: addNumBers"; connection "] =" http://tempuri.org/earning/additionalws/listallmajorsbyObjectID "; 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 ("soap", "," "); serializer-> startbody (" "); serializer-> startelement (" ListallmajorsbyObjectID "," http://tempuri.org/ Elearning / AdditionalWS ",", ""); Serializer-> StartElement ("ObjectID", ",", ""); serializer-> WriteString (L "11"); serializer-> endelement (); Serializer -> endelement (); serializer-> endbody (); serializer-> endenvelope (); connector-> endMESSAGE ();
Reader.createInstance (__ uuidof (SoapReader30));
Reader-> Load (_VARIANT_T ((iunknown *) connector-> outputstream), "" "
_BSTR_T RESULT = Reader-> rpcResult-> Text;
Msxml2 :: ixmldomdocumentptr pxmldom;
HRESULT HR;
Coinitialize (NULL);
hr = pXMLDom.CreateInstance (__ uuidof (DOMDocument40)); if (FAILED (hr)) {printf ( "Failed to instantiate DOMDocument40 class / n"); return;} pXMLDom-> async = VARIANT_FALSE; if (pXMLDom-> loadXML ( Result)! = variant_true) {Printf ("Failed Load XML Data from File./N%S/N", (LPCSTR) PXMLDOM-> Parseerror-> getReason ()); return;}
_bstr_t nodeName = "MAJORNAME"; _bstr_t nodeID = "MAJORID"; MSXML2 :: IXMLDOMNodeListPtr pNodeList = pXMLDom-> getElementsByTagName (nodeName); int nList = pNodeList-> length; MSXML2 :: IXMLDOMNodeListPtr pNodeValueList = pXMLDom-> getElementsByTagName (nodeID); CComboBox * combo = (CComboBox *) this-> GetDlgItem (IDC_COMBO1); for (int n = 0; n
BSTR_T BSNODEVALUE = PnodeValue-> text; // buf = (cstring *) pnodeValue-> text;
BSTR BSTRVALUE = :: sysallocstring (bsnodevalue); char * buf = _com_util :: ConvertBSTRTOSTRING (BSTRVALUE);
// buf = bsnodetext; // combo-> addstring ("aaa");
// Combo-> setdlgitemtext (n 1, "111"); // cstring aaa = "231231";
Combo-> addstring (BSNodeText); Combo-> SetWindowText (BUF); Combo-> setdlgitemtext (IDC_COMBO1, BUF); // setdlgitemtext (IDC_CBO1, STR); // setItemData (INDEX, DATA [i] .value); Combo -> Setitemdata (N, (DWORD) BUF);
Combo-> setcurseel (0);
} Then modify the webservice, add the soaprpcmethod () property, indicating that the RPC call mode is used, only in this way can only be called through the method of SOAP calls in the VC, otherwise the parameter called coming in is Nothing.