VC ++. Net calls WebService

Source: Internet
Author: User

Use Visual Studio. NET to call WebService, and the program example (unmanaged) is MFC. As for how to add web references, we will not go into details here. The following is the call sample code:

# Include "WebService. H "// Add a WebService proxy class reference </P> <p> void cmfcservicedlg: onbnclickedok () <br/>{< br/> coinitialize (null ); // because the generated code is based on ATL, You need to initialize com </P> <p> // proxy object <br/> authenticationservice: cauthenticationservice * CAS = new authenticationservice:: cauthenticationservice (); </P> <p> // you can call seturl to dynamically set the Web service address <br/> // cas-> seturl ("http: // localhost: 8080/authenticationservice? WSDL "); </P> <p> hresult hR = s_ OK; </P> <p> // ccombstr belongs to the smart type, you can manage the memory allocation by yourself <br/> ccombstr ret; <br/> ccombstr in1 = "1"; <br/> ccombstr in2 = "1 "; <br/> ccombstr in3 = "1"; <br/> ccombstr in4 = "1"; <br/> ccombstr in5 = "1 "; </P> <p> hR = cas-> authenticate (in1, in2, In3, in4, in5, & RET); // note, the returned value is in the pointer format </P> <p> If (failed (HR) <br/>{< br/> MessageBox ("Call failed! "); <Br/>}< br/> else <br/>{< br/> MessageBox (" Call successful! "); <Br/>}< br/> Delete CAS; <br/> couninitialize (); </P> <p>}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.