@ . ASMX, WCF. , / -, SOAP.
WCF - , - . , , , , - SOAP.
SoapUI, Java, -. WSDL, , - ( ) Http Client.
, - WCF. SOAP-, , :
public class Program
{
public static void Main(string[] args)
{
string endpoint = "http://www.html2xml.nl/Services/Calculator/Version1/Calculator.asmx";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(endpoint);
request.ContentType = "text/xml";
request.Method = "POST";
request.KeepAlive = false;
var proxyServer = new WebProxy("XX.XX.XX.XX", 1234);
proxyServer.Credentials = CredentialCache.DefaultCredentials;
request.Proxy = proxyServer;
string payload = @"<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">
<soapenv:Header/>
<soapenv:Body>
<tem:Add>
<tem:a>1</tem:a>
<tem:b>2</tem:b>
</tem:Add>
</soapenv:Body>
</soapenv:Envelope>";
byte[] byteArray = Encoding.UTF8.GetBytes(payload);
request.ContentLength = byteArray.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(byteArray, 0, byteArray.Length);
requestStream.Close();
HttpWebResponse response = null;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
response = (HttpWebResponse)ex.Response;
}
Console.WriteLine(string.Format("HTTP/{0} {1} {2}\n", response.ProtocolVersion, (int)response.StatusCode, response.StatusDescription));
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
Console.WriteLine(reader.ReadToEnd());
reader.Close();
requestStream.Close();
responseStream.Close();
response.Close();
}
}
SOAP, :
HTTP/1.1 200 OK
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AddResponse xmlns="http://tempuri.org/">
<AddResult>3</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>
, ASMX, , WCF - . HTTP-.
, :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:Add>
<tem:a>x</tem:a>
<tem:b>y</tem:b>
</tem:Add>
</soapenv:Body>
</soapenv:Envelope>
, - :
HTTP/1.1 500 Internal Server Error
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring> ... exception stacktrace here ... </faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
SoapUI Junit, - JMeter, , - (, SoapUI) SOAP. , .