1. Wayne Wan
  2. PowerBuilder
  3. Monday, 8 July 2019 16:10 PM UTC

My pb IDE: pb11

i call a webservice and it works well for serveral months. but it showed error last month, "HTTP 417".  i asked the server side, they told me to add this sentence before I call the webservice: "System.Net.ServicePointManager.Expect100Continue = false;"  

but it is a .NET method. How should i do in PB?  

thanks a lot. 

Wayne Wan Accepted Answer Pending Moderation
  1. Friday, 12 July 2019 15:34 PM UTC
  2. PowerBuilder
  3. # 1

it works!  Thank you, Roland Smith, David Peace. 

To Roland Smith,With your winhttp object, it works well! 

here is my code:

string xml
string ls_response
long  ll_length

inv_winhttp.Open("post", is_wsdl)
//the following line is no use.
//inv_winhttp.SetRequestHeader("Expect100Continue", "false")    
inv_winhttp.SetRequestHeader("Content-Type", "text/xml;charset=utf8")

xml =  ''
xml += '   '
xml += '   '
xml += '      '
xml += '         ' + is_user + ''
xml += '         '+is_pwd+''
xml += '         '+is_companycode+''
xml += '         '+is_version+''
xml += '         '+as_datatype+''
xml += '         '+as_sign+''
xml += '         '
xml += '      '
xml += '   '
xml += ''

ll_length = inv_winhttp.Send(xml)
If ll_length >= 0 Then
	ls_response = inv_winhttp.ResponseText
Else
	MessageBox("HTTP Post Error #" + &
					String(inv_winhttp.LastErrorNum), &
					inv_winhttp.LastErrorText, StopSign!)
End If

//here seems a little stupid. how to work with the response easily?
ls_response = gn_app.inv_strsrv.of_GlobalReplace(ls_response, "<", "<")
ls_response = gn_app.inv_strsrv.of_GlobalReplace(ls_response, ">", ">")
ls_response = gn_app.inv_strsrv.of_GlobalReplace(ls_response, """, '"')
ls_response = mid(ls_response, pos(ls_response, "") + 8)
ls_response = mid(ls_response, 1, pos(ls_response, "") - 1)


return ls_response

 

Comment
There are no comments made yet.
David Peace (Powersoft) Accepted Answer Pending Moderation
  1. Friday, 12 July 2019 09:08 AM UTC
  2. PowerBuilder
  3. # 2

Hi

We have some coade that makes a soap call using Rolands Stuff, the importnat part is the message header, see below.

Blob lblob_data, lblob_response
string ls_mimetype, ls_response, ls_return, ls_test
Integer li_rc, li_fnum
ULong lul_length
n_winhttp ln_http

// Validate data is set up correctly
if isnull(is_username) or isnull(is_password) or isnull(is_hotel) or isnull(is_hotel_code) then return false
if trim(is_username) = '' or trim(is_password) = '' or trim(is_hotel) = '' or trim(is_hotel_code) = '' then return false

if isnull(as_message) or trim(as_message) = '' then return false

// Get a new messageid
of_messageid( long(string(today(), 'yyyymmdd')), long(string(now(),'hhmmss')), 999, 1234, 10000001)

// Build Message
lblob_data = blob(of_message_header(true) + &
    '' + &
    '' + as_message + '',  EncodingANSI!)

// Get mimetype
ls_mimetype = ln_http.GetMIMEType('', lblob_data)

// Store the XML for now
ls_test = string(lblob_data, EncodingANSI!)

// Post SOAP Call
lul_length = ln_http.Postsoap(of_url(), &
            lblob_data, ls_mimetype, lblob_response,'OTA_PMS')
If lul_length > 0 Then
    // Data Returned
    ls_response = String(lblob_response, EncodingAnsi!)
    if pos(ls_response, 'Success') > 0 then
        ls_return = mid(ls_response, pos(ls_response, 'EchoData>') + 9, pos(mid(ls_response, pos(ls_response, 'EchoData>') + 10), '<') )
        if ls_return = as_message then
            Return True
        end if
    end if
    as_message = of_geterror(ls_response)
    return false
End If
ln_http.getlasterror( )
as_message = ln_http.lasterrortext
Return False

-------------------------------------------------------------------------------------------------------------------------------

Important bit, Message header function

string ls_header

long ll_cnt
string ls_mimetype, ls_response, ls_test
n_winhttp ln_http
ulong lul_length


of_messageid( long(string(today(), 'yyyymmdd')), long(string(now(),'hhmmss')), 999, 1234, 10000001)

ls_header = '' + &
    '
    'xmlns:ns ="http://www.opentravel.org/OTA/2003/05" ' + &
    'xmlns:oas ="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" ' + &
    'xmlns:add ="http://schemas.xmlsoap.org/ws/2004/08/addressing">' + &
    '' + &
    '

    ls_header += ':mustUnderstand = "1">'
    ls_header += '' + is_username + '' + &
                        '' + is_password + '' + &
                        ' ' + &

                        '' + is_messageid + ' '

    ls_header +=     'http://www.myhotel.com/ws/ota' + &
                            'http://www.myhotel.com/ws/ota/OTA_ReadRQ' + &
                            'http://schemas.xmlsoap.org/ws/2004/12/addressing/role/anonymous'
    ls_header += '    '
    
return ls_header

 

Hope that this helps.

Comment
There are no comments made yet.
Wayne Wan Accepted Answer Pending Moderation
  1. Wednesday, 10 July 2019 08:20 AM UTC
  2. PowerBuilder
  3. # 3

anyone can give me a suggestion?

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 8 July 2019 17:42 PM UTC
  2. PowerBuilder
  3. # 4

I read David's post and it seems as though somehow your client call is passing 'Expect: 100-continue' and the web service does not support that feature so it responds with the 417 Expectation Failed. You need to figure out how to stop your client from sending the expectation.

You haven't given us any details on how you are calling the web service so we can't be any more specific.

 

Comment
  1. David Peace (Powersoft)
  2. Tuesday, 9 July 2019 08:01 AM UTC
You will have to use the HTTP Client to make the call rather that the SOAP object. That will allow you to control the header settings.

Cheers

David
  1. Helpful
  1. Wayne Wan
  2. Wednesday, 10 July 2019 11:02 AM UTC
I read a sample code of userobject which name is n_xmlhttp(written by Roland Smith). but it only refered how to Get a page content or a image. how to call a webservice?

  1. Helpful
  1. Roland Smith
  2. Wednesday, 10 July 2019 12:42 PM UTC
Calling a SOAP webservice is done by doing a POST of XML with some HTTP Headers added first.

I think you will have better luck with the WinHTTP example as it has functions to add headers.

http://www.topwizprogramming.com/freecode_winhttp.html

  1. Helpful
There are no comments made yet.
David Peace (Powersoft) Accepted Answer Pending Moderation
  1. Monday, 8 July 2019 16:25 PM UTC
  2. PowerBuilder
  3. # 5

Hi

This article does explain the issue quite well:

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019LuWSAU&l=en-GB

It talks about the client sending the continue request if the message is over 1024 characters and is expecting a continue response from the server. If the server gives a 417 then it is saying no don't send that message.

Their work around is to not request continue on larger messages. The client HTTP header has Expect: 100-continue.

I know that this does not answer your question, but may help you to understand why they are suggesting the change.

You could try reducing the size of the message somehow?

Cheers

 

Comment
  1. Wayne Wan
  2. Tuesday, 9 July 2019 02:53 AM UTC
thanks. i read such articles just like it before.

i don't know how to reduce the message size. they provide a web service, and give us a tip about how to call the method. one of the parameters is a long xml string. i think maybe only sum those formatted tags will over 1024.

i have to say , PB is not a popular develop IDE here any more, and most of the young even never hear about it . that's why they only give a .Net solution. but my program was developed in PB. :(
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.