SOAP in version 6.9

wango

Member
Licensed User
Longtime User
Hi community,

this is my first try with Basic4ppc and I have an error which I can´t get rid of.

I use the SOAP-example from Erel (with nearly no modifiaction). In my old test IDE (version 6.8) it runs fine. Now I purchased the 6.9 to compile the program and finally use and the same source code doesn´t work anymore.

This is my sub:

Sub WriteVariableInteger (id, value)
ErrorLabel(error2)
Request.New1(URL) 'Build the request.
obj.New1(False)
obj.FromLibrary("Main.Request","req",B4PObject(2))
obj.Value = obj.GetProperty("Headers")
SoapAction = "urn:UIPSTypes-IIPSVariableManager#WriteVariableInteger"
obj.RunMethod3("Add","SoapAction","System.String",Chr(34) _
& SoapAction & Chr(34),"System.String") 'Set the SOAPAction header
Request.Method = "POST"
Request.ContentType = "text/xml"
newWrite = StrReplace(newwrite,"$$1",id) 'Replace the two parameters.
newWrite = StrReplace(newWrite,"$$2",value)
buffer() = bit.StringToBytes(newWrite,0,StrLength(newWrite))
Request.ContentLength = ArrayLen(buffer())
bin.New1(Request.GetStream,True)
bin.WriteBytes(buffer())
Request.TimeOut = 30000 '30 seconds
Response.New1
Response.Value = Request.GetResponse 'Call the server
result = Response.GetString 'Get the string from the response stream.
Response.Close
Return result
error2:
Msgbox("Communication error.")
Return 0
End Sub

Any idea?

Thanks in advance

Boris
 

klaus

Expert
Licensed User
Longtime User
What error you get ?
The best way to get a concrete answer is to explain the error you get and also to post your whole code, otherwise we need to try to find the code you are refering to and try to find out what the problem could be.

I suspect that you get the error in this line:
buffer() = bit.StringToBytes(newWrite,0,StrLength(newWrite))

You should replace in the Global routine:
Dim buffer(0)
by
Dim buffer(0) as Byte

Best regards.
 

wango

Member
Licensed User
Longtime User
First of all thanks for the brilliant support, the response time in this forum is lightning fast. Sorry that I just skipped the most important part, but the solution from Klaus was just the right one.

But now I have another strange thing. When I start compiling I receive the error:

"Index was out of range. Must be non-negative and less than the size of the collection
Line number: 132
Line: WriteVariableInteger(54134, stunde)"

The variable stunde is ok, it doesn´t even work if I replace "stunde" by "1".

And here is the whole code of WriteVariableInteger:


Sub Globals
Dim buffer(0) As Byte
Dim write
URL = "http://192.168.3.2:3773/soap/IIPSVariableManager"
End Sub

Sub App_Start
FileOpen(c2,"write.txt",cRead) 'Read the SOAP message
write = FileReadToEnd(c2)
FileClose(c2)
bit.New1
obj.New1(False)

Sub WriteVariableInteger (id, value)
ErrorLabel(error2)
Request.New1(URL) 'Build the request.
obj.New1(False)
obj.FromLibrary("Main.Request","req",B4PObject(2))
obj.Value = obj.GetProperty("Headers")
SoapAction = "urn:UIPSTypes-
IIPSVariableManager#WriteVariableInteger"
obj.RunMethod3("Add","SoapAction","System.String",Chr(34) _
& SoapAction & Chr(34),"System.String") 'Set the SOAPAction header
Request.Method = "POST"
Request.ContentType = "text/xml"
newWrite = StrReplace(write,"$$1",id) 'Replace the two parameters.
newWrite = StrReplace(newWrite,"$$2",value)
buffer() = bit.StringToBytes(newWrite,0,StrLength(newWrite))
Request.ContentLength = ArrayLen(buffer())
bin.New1(Request.GetStream,True)
bin.WriteBytes(buffer())
Request.TimeOut = 30000 '30 seconds
Response.New1
Response.Value = Request.GetResponse 'Call the server
result = Response.GetString 'Get the string from the response stream.
Response.Close
Return result
error2:
Msgbox("Communication error.")
Return 0
End Sub
 

wango

Member
Licensed User
Longtime User
Here are all the files.

Sorry just a newbie fault...
 

Attachments

  • wecker0_2.sbp
    15.9 KB · Views: 186
  • read.txt
    544 bytes · Views: 255
  • write.txt
    560 bytes · Views: 186

wango

Member
Licensed User
Longtime User
Sorry for the trouble, the forum doesn´t like .ini files as upload. Now everything as .zip.

Boris
 

Attachments

  • wecker.zip
    4.7 KB · Views: 198

wango

Member
Licensed User
Longtime User
Hello Klaus,

yes this should be normal. You don´t have the SOAP-Service running on the server specified in the script. So the msgbox with the communication error is normal.

Do you get the same error, when trying to compile the script? It seems that the compiler thinks it is an array, but I don´t see why.

Thanks for your help in advance
 

wango

Member
Licensed User
Longtime User
I tried to get versions like the ones you posted, but didn´t find them anywhere. I think in my installation are the newest versions, becuase I downloaded it just yesterday. The versions I can find in the properties of the dll´s are :
Hardware 1.0.3515.36372
HTTP 1.0.3262.41711
BinaryFile 1.0.2860.34201
Bitwise 1.0.2860.34237
Door 1.0.3494.28661

I tried to use older version from the forum, but they are exchanged, when I start Basic4PPC.
 

wango

Member
Licensed User
Longtime User
Hi Klaus,

the error message is: "Index was out of range. Must be non-negative and less than the size of the collection
Line number: 132
Line: WriteVariableInteger(54134, stunde)"

I tried another thing and installed Basic4ppc on another computer, this fixes the problem.

Just one thing left that is strange. I uninstalled Basic4PPC on my first computer and installed it again. But this doesn´t fix the problem it seems the unistall routine doesn´t remove everything. I will check tomorrow wahat the uninstall routine leaves on my computer. If I can´t fix this I can only compile on my homeserver.


Thanks for your help Klaus


Boris
 

klaus

Expert
Licensed User
Longtime User
Try to install B4PPC in a new folder by changing the default folder name.
I have installed all the last version in new folders. I still have versions 6.5 and 6.8 which are still working besides version 6.9. The only thing is that you must copy the the license.txt file into the new folder.

Best regards and good luck.
 

wango

Member
Licensed User
Longtime User
I solved the problem! After installing Basic4PPC new I can compile the programm. Strange problem.

Thanks for the help
 
Top