1. New User
  2. PowerBuilder
  3. Friday, 12 August 2022 07:35 AM UTC

Hello, 

 

i am trying to consume a WCF service and i am getting status code 400(Bad Request)  in httpclient response. can anyone guide me what is wrong in consuming / calling the service ?

i want to call "GetCMSWorkQueue"method of service wkfqueuemanager.svc, can somebody tell me what's the problem

service

 

PB code

 

httpClient lo_client
integer li_ret , i , li_StatusCode
String lo_xml_request
string ls_url
string ls_data
string ls_body
string ls_ret


ls_url ="http://130.0.238.12:55555/wkfqueuemanager.svc/GetCMSWorkQueue"

ls_body = '<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"><soapenv:Header/><soapenv:Body><tem:ReceiveRequestNotifications><!--Optional:--><tem:userName>t3</tem:userName><!--Optional:--><tem:flag>F</tem:flag></tem:ReceiveRequestNotifications></soapenv:Body></soapenv:Envelope>'


lo_client = Create httpClient

//lo_client.SetRequestHeader("Content-Type", "text/xml")

lo_client.SetRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")


lo_client.sendrequest('POST',ls_url,ls_body)

li_StatusCode = lo_client.GetResponseStatusCode()


ls_ret = lo_client.GetResponseStatusText( )


li_ret = lo_client.getresponsebody( ls_data)

destroy lo_client

 

Error

statuscode 400

"Bad Request"

René Ullrich Accepted Answer Pending Moderation
  1. Friday, 12 August 2022 08:07 AM UTC
  2. PowerBuilder
  3. # 1

The message says that it expects application/soap+xml. You send text/xml.

Change the SetrequestHeader call to set the Content-Type as server needs.

Comment
  1. New User
  2. Friday, 12 August 2022 09:53 AM UTC
i have set like

lo_client.SetRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")

but still get the same "Bad Request" response.

can you check body code. i copied this code from soupui. is it what which i should put in body ?

ls_body ='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:tem="http://tempuri.org/"><soapenv:Header/><soapenv:Body><tem:GetCMSWorkQueue><!--Optional:--><tem:userName>t3</tem:userName></tem:GetCMSWorkQueue></soapenv:Body></soapenv:Envelope>'



  1. Helpful
  1. Brad Mettee
  2. Friday, 12 August 2022 12:45 PM UTC
In the SOAPUI window, the URL you have is mixed case, and your code has it in all lower (for the first portion). Request might be failing if webservice is case sensitive. It's also a different spelling.

code = wkfqueuemanager.svc

sample=WKFMSMQManager.svc
  1. Helpful 1
  1. New User
  2. Friday, 12 August 2022 13:30 PM UTC
sorry i uploaded the wrong pic now i have updated
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 12 August 2022 12:58 PM UTC
  2. PowerBuilder
  3. # 2
Comment
  1. New User
  2. Friday, 12 August 2022 13:31 PM UTC
i have already looked and followed the steps but getting the same bad request response
  1. Helpful 1
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Friday, 12 August 2022 13:07 PM UTC
  2. PowerBuilder
  3. # 3

I'd used postman to get it to work, to eliminate coding things wrong.  Once you can call it correctly, it will be easier to get it to work in whatever you are writing the program in.

Comment
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.