C ++ builder calls C #'s WebService

Source: Internet
Author: User

1. Imported service. cpp
//************************************** **********************************//
// The types declared in this file were generated from data read from
// WSDL file described below:
// WSDL: http: // localhost: 1043/web/service. asmx? WSDL
//> Import: http: // localhost: 1043/web/service. asmx? WSDL: 0
// Encoding: UTF-8
// Version 1.0
// (21:50:12--$ Rev: 7010 $)
//************************************** **********************************//

# Include <VCL. h>
# Pragma hdrstop

# If! Defined (serviceh)
# Include "service. H"
# Endif

Namespace ns_service {

_ Di_servicesoap getservicesoap (bool usewsdl, ansistring ADDR, thttprio * httprio)
{
Static const char * defwsdl = "http: // localhost: 1043/web/service. asmx? WSDL ";
Static const char * defurl = "http: // localhost: 1043/web/service. asmx ";
Static const char * defsvc = "service ";
Static const char * defprt = "servicesoap ";
If (ADDR = "http://www.blog.com.cn /")
ADDR = usewsdl? Defwsdl: defurl;
Thttprio * Rio = httprio? Httprio: New thttprio (0 );
If (usewsdl ){
Rio-> wsdllocation = ADDR;
Rio-> service = defsvc;
Rio-> Port = defprt;
} Else {
Rio-> url = ADDR;
}
_ Di_servicesoap service;
Rio-> QueryInterface (service );
If (! Service &&! Httprio)
Delete Rio;
Return service;
}

//************************************** **********************************//
// This routine registers the interfaces and types exposed by the WebService.
//************************************** **********************************//
Static void regtypes ()
{
/* Servicesoap */
Invregistry ()-> registerinterface (_ interfacetypeinfo (servicesoap), L "http://tempuri.org/", l "UTF-8 ");
Invregistry ()-> registerdefasosoapaction (_ interfacetypeinfo (servicesoap), L "http://tempuri.org/%operationName% ");
Invregistry ()-> registerinvokeoptions (_ interfacetypeinfo (servicesoap), iodocument );
}
# Pragma startup regtypes 32

}; // Ns_service

========================================================== ==============
2. Service. h
//************************************** **********************************//
// The types declared in this file were generated from data read from
// WSDL file described below:
// WSDL: http: // localhost: 1043/web/service. asmx? WSDL
//> Import: http: // localhost: 1043/web/service. asmx? WSDL: 0
// Encoding: UTF-8
// Version 1.0
// (21:50:12--$ Rev: 7010 $)
//************************************** **********************************//

# Ifndef serviceh
# Define serviceh

# Include <system. HPP>
# Include <invokeregistry. HPP>
# Include <xsbuiltins. HPP>
# Include <soaphttpclient. HPP>

# If! Defined (soap_remotable_class)
# Define soap_remotable_class _ declspec (delphiclass)
# Endif
# If! Defined (is_optn)
# Define is_optn 0x0001
# Endif

Namespace ns_service {

//************************************** **********************************//
// The following types, referred to in the WSDL document are not being represented
// In this file. They are either aliases [@] of other types represented or were referred
// To but never [!] Declared in the document. The types from the latter category
// Typically map to predefined/known XML or Borland types; however, they cocould also
// Indicate incorrect WSDL documents that failed to declare or import a schema type.
//************************************** **********************************//
//! : String-"http://www.w3.org/2001/XMLSchema"

//************************************** **********************************//
// Namespace: http://tempuri.org/
// Soapaction: http://tempuri.org/%operationName%
// Transport: http://schemas.xmlsoap.org/soap/http
// Style: Document
// Binding: servicesoap
// Service: Service
// Port: servicesoap
// URL: http: // localhost: 1043/web/service. asmx
//************************************** **********************************//
_ Interface interface_uuid ("{77573149-9c57-fa51-f11f-efd527c91bd9}") servicesoap: Public iinvokable
{
Public:
Virtual widestring test () = 0;
Virtual widestring Test2 (const widestring S) = 0;
};
Typedef delphiinterface <servicesoap> _ di_servicesoap;

_ Di_servicesoap getservicesoap (bool usewsdl = false, ansistring ADDR = "", thttprio * httprio = 0 );

}; // Ns_service

# If! Defined (no_implicit_namespace_use)
Using namespace ns_service;
# Endif

# Endif // serviceh
========================================================== ==============================
3. Call Code
Ns_service: _ di_servicesoap P = ns_service: getservicesoap (true, "", null );
Widestring S = "OK ";
Widestring STR = p-> Test2 (s );
P-> test ();
Messageboxw (null, str. c_bstr (), null, mb_ OK );

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.