VB6 또는 ASP에서 웹 서비스를 수행하십시오
웹 서비스 기술을 통해 이기종 컴퓨팅 환경은 데이터 및 커뮤니케이션을 공유하여 정보의 일관성을 달성 할 수 있습니다. 우리는 사용할 수 있습니다
HTTP Post/Get 프로토콜, 웹 서비스를 호출하는 비누 프로토콜.
1. 비누 프로토콜을 사용하여 vb6에서 웹 서비스를 호출하십시오.
먼저 .NET을 사용하여 간단한 웹 서비스를 해제합니다
<webMethod ()> _
public function getString (byval str as string)
Hello World, & str &!
엔드 기능
웹 서비스에는 문자열을 반환하기 위해 하나의 getString 메소드 만 포함되어 있습니다. 이 웹 서비스를 호출 할 때 .smx 페이지로 전송 된 비누 메시지는 다음과 같습니다.
<? xml 버전 = 1.0 인코딩 = UTF-8?>
<비누 : 봉투 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/>
<비누 : 바디>
<getString xmlns = http://tempuri.org/testwebservice/service1>
<str> 문자열 </strong
</getString>
</soap : body>
</soap : 봉투>
반환 된 비누 메시지는 다음과 같습니다.
<? xml 버전 = 1.0 인코딩 = UTF-8?>
<비누 : 봉투 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/>
<비누 : 바디>
<getStringResponse xmlns = http://tempuri.org/testwebservice/service1>
<getStringrsult> 문자열 </getStringresult>
</getStringResponse>
</soap : body>
</soap : 봉투>
VB6 의이 간단한 웹 서비스는 XMLHTTP 프로토콜을 사용하여 .AMSX 페이지로 보낼 수 있습니다.
구현에 비누를 보냅니다.
VB6에서는 간단한 프로젝트를 작성하면 인터페이스가 그림에 표시됩니다
단일 웹 서비스
strxml을 문자열로 희미하게합니다
문자열로 Dim Str
str = text2.text
'비누 메시지를 정의하십시오
strxml = <? xml 버전 = '1.0'encoding = 'utf-8'?> <soap : 봉투
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/'> <sap : body> <getstring xmlns = 'http : //tempuri.org/testwebservice/service1'> <str> & str &
</strong </getstring> </soap : body> </soap : 봉투>
'HTTP 객체 정의, 서버로 게시물 메시지를 보냅니다.
msxml2.serverxmlhttp40으로 dim h
'XML의 문서 개체를 정의하고 필기 또는 허용 된 XML 컨텐츠를 XML 객체로 변환하십시오.
MSXML2.Document40으로 X를 DIM
'XML 객체 초기화
x = 새로운 msxml2.document40을 설정합니다
'필기 된 비누 문자열을 XML 객체로 변환하십시오
x.loadxml strxml
'HTTP 객체를 초기화하십시오
H = 새로운 MSXML2.SERVERXMLHTTP40을 설정합니다
'지정된 URL에 게시물 메시지를 보냅니다
h.open post, http : //localhost/testwebservice/service1.asmx, false
H. SetRequestHeader Content-Type, Text/XML
H.send (stxml)
H.readystate <> 4
향하게 하다
'반환 된 XML 정보를 보여줍니다
text1.text = h.responsetext
'반환 된 XML 정보를 분석하고 반환 값을 표시합니다.
x = 새로운 msxml2.document40을 설정합니다
x.loadxml text1.text
text1.text = x.childnodes (1) .text
우리는 TextBox 및 클릭 버튼에 "China"를 입력하므로 아래의 TextBox에 "Hello World, China"를 표시 할 수 있습니다. 그림과 같이 표시하십시오.