Home > database >  Solution: use PB6.5 invoke the Web Service method
Solution: use PB6.5 invoke the Web Service method

Time:09-20

OLE invoke MSSOAP. SoapClient implementation, this method can be used in the low version of pb, as pb6.5,
5. MSSOAPLib. SoapClient available, please download from the Microsoft search soap toolkit soapsdk. Exe

OLEObject MSSOAPLib1
MSSOAPLib1=CREATE OLEObject
Long ll_result
Ll_result=MSSOAPLib1. ConnectToNewObject (" MSSOAP. SoapClient ")
If ll_result & lt;> 0 then
Messagebox (" prompt ", "connect MSSOAP SoapClient failure! Return parameter: "+ string (ll_result))
End the if
MSSOAPLib1. Mssoapinit (" http://172.17.99.20:9090/yygh/services/Query? WSDL ")
Mle_content. Text=MSSOAPLib1. SendXml (" Sina, "sle_userid. Text, sle_passwd. Text, sle_mobileno. Text, mle_content. The Text," new ")
Solution: I run MSSOAPLib1 mssoapinit error!

CodePudding user response:

What is your webservice language development?

May use agreement mssoap does not support

CodePudding user response:

Pb6.5 can support the.net development webservices, but calling Java development webservices abnormal

CodePudding user response:

Quote from: heaven programmer
WebService PowerBuilder6.5 call
Recently and other companies do interface, a web service, so we need to make calls in the owerBuilder6.5, looked on Google, etc, that are using MSSOAP. The SoapClient or MSXML. XMLHTTP, found after a specific test is not very ideal, so want to whether PB6 local GetURL function can be directly used for? So have the following plan:
Begin from internetresult n_ir_wsclient inheritance object, and defines the instance variable dataResult used to hold GetURL returns results, so that you can proceed to the WebService call
 
Inet lnv_inet

N_ir_wsclient lnv_wsclient

The Integer li_return

String ls_url, ls_data


Lnv_inet=Create Inet

Lnv_wsclient=Create n_ir_wsclient


Ls_url="HTTP://http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo? MobileCode=1380571 & amp; UserID="


Li_return=lnv_inet. GetURL (ls_url lnv_wsclient)


Ls_data=https://bbs.csdn.net/topics/String (lnv_wsclient dataResult)


Destroy lnv_wsclient

Destroy lnv_inet


At this time to return the result as follows:

 
<? The XML version="1.0" encoding="utf-8"?>



Trouble, return the result is utf-8, but PB65 does not support direct transformation, how to do? Finally consider or assist a DLL, so COnvCode. DLL out,
 
The Function of Integer UTF8ToAnsii (String szUTF8, Ref String szAnsiiRslt) Library "ConvCode. DLL" Alias For "_UTF8ToAnsii @ 8"

The Function of Integer AnsiiToUTF8 (String szAnsii, Ref String szUTF8Rslt) Library "ConvCode. DLL" Alias For "_AnsiiToUTF8 @ 8"

Finally complete the function also out
 
Inet lnv_inet

N_ir_wsclient lnv_wsclient

The Integer li_return

String ls_url ls_data, ls_result

Long ll_length



Ls_url=arg_url

//1. Turn the URL utf-8

SetNull (ls_result)

Ll_length=AnsiiToUTF8 (ls_url, Ref ls_result)

Ls_result=Space (ll_length)

Ll_length=AnsiiToUTF8 (ls_url, Ref ls_result)

If ll_length & lt; 0 Then

LastError=- 100

Return ""

End the If

Ls_url=ls_result


//2, perform WebService

Lnv_inet=Create Inet

Lnv_wsclient=Create n_ir_wsclient


Li_return=lnv_inet. GetURL (arg_url lnv_wsclient)


Ls_data=https://bbs.csdn.net/topics/String (lnv_wsclient dataResult)


Destroy lnv_wsclient

Destroy lnv_inet


If li_return & lt; 0 Then

LastError=li_return

Return ""

End the If



//3, turn processing returns results, utf-8 ANSII

SetNull (ls_result)

Ll_length=UTF8ToAnsii (ls_data, Ref ls_result)


Ls_result=Space (ll_length)

Ll_length=UTF8ToAnsii (ls_data, Ref ls_result)

If ll_length & lt; 0 Then

LastError=- 100

Ls_result=""

End the If


//4, return

Return ls_result

Add:
ConvCode. The core of the DLL source code is as follows:
 
INT WINAPI __declspec (dllexport) UTF8ToAnsii (LPCSTR szUTF8, LPSTR szAnsiRslt)
{
INT nResult=0;
//conversion, are required for the size of the space
Int wcsLen=MultiByteToWideChar (CP_UTF8, 0, szUTF8, strlen (szUTF8), NULL, 0).
//allocate space to leave a space, '\ 0' MultiByteToWideChar not give '\ 0' space
LPWSTR wszString=(LPWSTR) (malloc sizeof (wcsLen (+ 1) * (WCHAR)));

//conversion
MultiByteToWideChar (CP_UTF8, 0, szUTF8, strlen (szUTF8), wszString, wcsLen);
//then add '\ 0'
WszString [wcsLen]='\ 0';

//conversion, are required for the size of the space, this time with the function of contrary to the above name
Int ansiLen=WideCharToMultiByte (CP_ACP, 0, wszString, wcslen (wszString), NULL, 0, NULL, NULL);

NResult=ansiLen + 1;
If (szAnsiRslt!//NULL===NULL) & gt; Only need character space size
{
//same as above, allocate space for '\ 0'
leave a spaceLPSTR szAnsi=(LPSTR) (malloc ((ansiLen + 1) * sizeof (CHAR)));
//conversion
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related