Question : Error while importing web service

Hi all experts,

I have a problem with importing third-party web service to my .NET application. Framework version 2.0. When I'm adding a web reference, I'm getting following errors:

Custom tool error: Unable to import WebService/Schema. Unable to import binding 'IST_ExchWebServicebinding' from namespace 'http://tempuri.org/'. The operation 'TransferEMCOSData' on portType 'IST_ExchWebService' from namespace 'http://tempuri.org/' had the following syntax error:  The operation has no matching binding. Check if the operation, input and output names in the Binding section match with the corresponding names in the PortType section.


Custom tool error: Unable to import WebService/Schema. Unable to import binding 'IST_ExchWebServicebinding' from namespace 'http://tempuri.org/'. The operation 'TransferEMCOSData' on portType 'IST_ExchWebService' from namespace 'http://tempuri.org/' had the following syntax error:  The operation has no matching binding. Check if the operation, input and output names in the Binding section match with the corresponding names in the PortType section.

WSDL file is attached (IP is masked by me)

Thank you in advance.

Answer : Error while importing web service

Hi all,

Finaly I found some solution. It is primitive, yet effective. I have obtained SOAP message from another client. Now I'm constructing raw SOAP message based on this example and sending it to web service. I will ask mods to accept my own answer as solution. Here's complete code:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
byte[] iarBytes;

            string sBoundary = "MIME_boundaryS0M3B0UnDAry2121";

            //Load Message header
            string sHead = File.ReadAllText(@"C:\Temp\Head.txt");

            //Load Envelope tamplate
            string sEnvelope = File.ReadAllText(@"C:\Temp\Envelope.xml");

            //Pass parameters
            sEnvelope = sEnvelope.Replace("###UserId###", txtUserId.Text);
            sEnvelope = sEnvelope.Replace("###Func###", txtFunc.Text);

            //Generate ContentId for attachment
            Guid cid = Guid.NewGuid();
            sEnvelope = sEnvelope.Replace("###ContentId###", cid.ToString());

            string sAttachment = txtAttachment.Text;

            //Create SOAP message
            string sSOAP = "";
            //Add boundary
            sSOAP += "\r\n--" + sBoundary + "\r\n";
            //Add header
            sHead = sHead.Replace("###ContentLength###", sEnvelope.Length.ToString());
            sSOAP += sHead;
            //Add Envelope
            sSOAP += sEnvelope;
            //Add boundary
            sSOAP += "\r\n--" + sBoundary + "\r\n";
            //Add attachment
            sSOAP += "Content-ID: <" + cid.ToString() + ">\r\n";
            sSOAP += "Content-Length: " + sAttachment.Length.ToString() + "\r\n";
            sSOAP += "Content-Type: application/binary\r\n\r\n";
            sSOAP += sAttachment;
            //Add boundary
            sSOAP += "\r\n--" + sBoundary;
            
            //Create web request
            HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(@"http://xx.xx.xx.xx:xxxx/STWS/STExchangeWS.dll/soap/IST_ExchWebService");
            wr.ReadWriteTimeout = 30000;
            wr.Method = "POST";
            wr.ContentType = @"multipart/related; boundary=MIME_boundaryB0R9532143182121";            
            
            //Convert string to bytes            
            Encoding enc = Encoding.GetEncoding(1257);
            iarBytes = enc.GetBytes(sSOAP);
            wr.ContentLength = iarBytes.Length;

            //Send post
            Stream str = wr.GetRequestStream();            
            str.Write(iarBytes, 0, iarBytes.Length);
            str.Close();

            //Get response
            WebResponse resp = wr.GetResponse();
            str = resp.GetResponseStream();

            MemoryStream mstr = new MemoryStream();
            iarBytes = new byte[1024];
            int iBytesRead = 0;

            do
            {
                iBytesRead = str.Read(iarBytes, 0, iarBytes.Length);
                mstr.Write(iarBytes, 0, iBytesRead);
            } while (iBytesRead != 0);

            str.Close();

            //Write response to file
            iarBytes = mstr.ToArray();
            mstr.Close();
            File.WriteAllBytes(@"C:\Temp\soap.txt", iarBytes);
Random Solutions  
 
programming4us programming4us