C # calling the soap Web Service compiled by Delphi (1)

Source: Internet
Author: User

C # How do I call the soap Web Service written in Delphi?

There are two methods available on the Internet,

1. Introduction of wrapper from WSDL by adding web refrence in vistual studio. However, type errors are always reported and it is suspected that certain types such as olevariant may not be supported. However, by carefully checking the vs warning information, it is found that some complex types inherited from tremoteable are not output in the WSDL. Delphi's WSDL only outputs the definitions of complex originals directly used in interfaces. If multi-layer inheritance exists, the original will not be output if it is not directly used. Therefore, a few unused functions are added to the interface to use these classes. Then re-import from vs, "add service reference...", succeeded.

But the call still failed. error message:

The content type of the Response Message text/html; charset = iso-8859-1 does not match the content type of the binding (text/XML; charset = UTF-8. If you use a custom encoder, make sure that the iscontenttypesupported method is correctly implemented. The first 541 bytes of the response are: "<! Doctype HTML public "-// IETF // dtd html 2.0 // en"> <HTML> 

My soap service is installed in Apache and the debugging parameters are set to-X-w-F "D: \ Program Files (x86) \ Apache Software Foundation \ apache2.2 \ conf \ httpd. conf ", close the service, run in Delphi, start tracking,

I tracked my Delphi Xe version 15.0.3953.35171 and found an error in webbrokersoap. PAS:

Function thttpsoapdispatcher. dispatchrequest (Sender: tobject; Request: twebrequest; Response: twebresponse): Boolean ;.............. if ismultipart then begin bindingtypein: = btmime; mimestream. processmultipartform (reqstream, xmlstream, string (request. contenttype), nil, converter. attachments, converter. tempdir); End else begin {load the SOAP envelope directly into the xmlstream} bindingtypein: = btsoap; xmlstream. copyfrom (reqstream, 0); // This line reports the error "stream read error" end;

Continue to trace to classes. procedure tstream of PAS. readbuffer (VAR buffer; count: longint); In the function, it is found that it needs to read 371 bytes, but read 0 bytes, so this error is reported.
Why?

Use the tcptrace (http://www.pocketsoap.com/tcptrace/) tool to see what C # has passed out:

POST /TMTS/DCSoapServerBrokerIIS_Standalone.dll/soap/ISoapService HTTP/1.1Content-Type: text/xml; charset=utf-8VsDebuggerCausalityData: uIDPo8jCedmtWQBDtUt1GRtNFUMAAAAAwwzVtxpxcEuCzmB2DZGPYO0IUNfw4PRNv2+9V5Cp2fEACQAASOAPAction: "urn:tmSoapInt-ISoapService#Test_Sum"Host: localhost:8080Content-Length: 372Expect: 100-continueAccept-Encoding: gzip, deflateConnection: Keep-Alive<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">  <s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns:xsd="http://www.w3.org/2001/XMLSchema">    <q1:Test_Sum xmlns:q1="urn:tmSoapInt-ISoapService">      <A xsi:type="xsd:int">3</A>      <B xsi:type="xsd:int">4</B>    </q1:Test_Sum>  </s:Body></s:Envelope>

If you use "add web reference..." In vs to import the WSDL, the import is successful, but the execution still fails. The information intercepted by tcptrace is:

POST /TMTS/DCSoapServerBrokerIIS_Standalone.dll/soap/ISoapService HTTP/1.1User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.261)VsDebuggerCausalityData: uIDPo7B2LBy0PhlHmITzVeouookAAAAAb8BWzvTMh0SX09/DtaGIO38HgmbNMpxDgAxyODAZkEcACQAAContent-Type: text/xml; charset=utf-8SOAPAction: "urn:tmSoapInt-ISoapService#Test_Sum"Host: localhost:8080Content-Length: 564Expect: 100-continueConnection: Keep-Alive<?xml version="1.0" encoding="utf-8"?><soap:Envelope   xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"   xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"   xmlns:tns="http://tempuri.org/"   xmlns:types="http://tempuri.org/encodedTypes"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns:xsd="http://www.w3.org/2001/XMLSchema">  <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">    <q1:Test_Sum xmlns:q1="urn:tmSoapInt-ISoapService">      <A xsi:type="xsd:int">3</A>      <B xsi:type="xsd:int">4</B>    </q1:Test_Sum>  </soap:Body></soap:Envelope>

What is the difference in the format? Why does Delphi's Web Service refuse to accept it?

Related Article

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.