Форум: "Сети";
Текущий архив: 2006.08.13;
Скачать: [xml.tar.bz2];
ВнизSOAP, вызов метода веб сервиса Найти похожие ветки
← →
maep (2006-02-15 10:20) [0]Начал тренероваться с SOAP.
Хочу сделать следующую вещь: есть веб сервис написанный C# с методом HelloWorld.
Есть приложение дельфи ( ну почему бы и не дельфи), которое через сокет коннектится к
веб срерверу и отправляет запрос с целью вызвать метод HelloWorld.
Делается это примерно так:
procedure TForm1.Button1Click(Sender: TObject);
var
s : string;
b : boolean;
begin
b := TcpClient1.Connect;
if not b then
begin
ShowMessage("connect failed");
exit;
end;
TcpClient1.Sendln("POST /WebSite1/Service.asmx HTTP/1.1 Host: http://localhost:1169/WebSite1/Service.asmx Content-Type: text/xml; charset=utf-8 " +
"Content-Length: 1000 SOAPAction: "http://tempuri.org/HelloWorld" <?xml version="1.0" " +
"encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" " +
"xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> " +
" <soap:Body> <HelloWorld xmlns="http://tempuri.org/" /> </soap:Body> </soap:Envelope>" + #$D#$A);
ИЛИ
TcpClient1.Sendln(
"<?xml version="1.0" encoding="UTF-8" standalone="no" ?> " +
"<SOAP:Envelope> " +
" <SOAP:Body> " +
" <SOAP:HelloWorld " +
" </SOAP:HelloWorld> " +
" </SOAP:Body> " +
"</SOAP:Envelope> " + #$D#$A);
TcpClient1.Close;
end;
В обоих случаях имеем
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="WebDev.WebHost"
StackTrace:
at Microsoft.VisualStudio.WebHost.Request.IsBadPath()
at Microsoft.VisualStudio.WebHost.Request.TryParseRequest()
at Microsoft.VisualStudio.WebHost.Request.Process()
at Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Connection conn)
at Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Connection conn)
at Microsoft.VisualStudio.WebHost.Server.OnSocketAccept(Object acceptedSocket)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
Помогите пожалуйста разобраться с этим делом..
тестовая страничка микрософт пишет что надо делать так:
SOAP 1.1
The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.
POST /WebSite1/Service.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/HelloWorld"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorld xmlns="http://tempuri.org/" />
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorldResponse xmlns="http://tempuri.org/">
<HelloWorldResult>string</HelloWorldResult>
</HelloWorldResponse>
</soap:Body>
</soap:Envelope>
← →
msi (2006-03-28 11:31) [1]А зачем так извращаться?
Я сейчас занимаюсь подобной проблемой.
В Делфи есть визард для создания прокси класса (WSDL Importer), полученный прокси клас объявляет интерфейс который можно использовать в клиенте, делается все очень просто.
Страницы: 1 вся ветка
Форум: "Сети";
Текущий архив: 2006.08.13;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.043 c