使用Netcat呼叫Webservice(SOAP)
Command line:
nc 192.168.2.48 80 < post6.txt
post6.txt內容:
POST /webservicetest/Service1.asmx HTTP/1.1
Host: 192.168.2.48
Content-Type: text/xml; charset=utf-8
Content-Length: 303
SOAPAction: "WebServiceTest/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="WebServiceTest" />
</soap:Body>
</soap:Envelope>
不會自動結束通訊的解決辦法:
nc 192.168.2.48 80 < post6.txt
post6.txt內容:
POST /webservicetest/Service1.asmx HTTP/1.1
Host: 192.168.2.48
Content-Type: text/xml; charset=utf-8
Content-Length: 303
SOAPAction: "WebServiceTest/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="WebServiceTest" />
</soap:Body>
</soap:Envelope>
原因:
在http1.1中,client和server都是默认对方支持长链接的, 如果client使用http1.1协议,
但又不希望使用长链接,则需要在header中指明connection的值为close;
留言
張貼留言