cancel
Showing results for 
Search instead for 
Did you mean: 

PB & web service : how to manipulate soap envelop ?

Former Member
0 Kudos
232

Hi all,

I am in the process of testing PB's ability to consume an existing web service. I have done some reading left and right.

I can create the proxy , but i always end up having the Cannot invoke webservice messagebox.

Here's my little piece of PB code 

PB CODE START

soapconnection conn // Define SoapConnection

checkvatport proxy_obj // Declare proxy

long rVal, lLog

real amount

date date_a

string ls_a,ls_b,ls_c

conn = create soapconnection  //Instantiated connection

lLog = conn.SetSoapLogFile ("C:\mySoapLog.log")

rVal = Conn.CreateInstance(proxy_obj, "checkvatport", "")

messagebox("test rval",string(rval))

// Create proxy object

try

   date_a = today()

  boolean w_t

  w_t = TRUE

   str_checkvat str1

   tns1__checkvatresponse str2

  str1.countrycode = "BE"

  str1.vatnumber = "0810416786"

  ls_a  = proxy_obj.checkvat(str1.countryCode,str1.vatNumber,str2.requestdate,str2.valid,str2.address)

 

  messagebox("LS-a",ls_a)

catch ( SoapException e )

   messagebox ("Error", "Cannot invoke Web service")

   // error handling  

end try

destroy conn

PB CODE END

And here's the soaplog contents

SOAPLOG START

CLOSED

REQUEST:

CLOSED

POST /taxation_customs/vies/services/checkVatService HTTP/1.1

Host: ec.europa.eu

Connection: Keep-Alive

User-Agent: EasySoap++/0.6

Content-Type: text/xml; charset=utf-8

SOAPAction: "urn:ec.europa.eu:taxud:vies:services:checkVat#checkVat"

Content-Length: 654

<E:Envelope

  xmlns:E="http://schemas.xmlsoap.org/soap/envelope/"

  xmlns:A="http://schemas.xmlsoap.org/soap/encoding/"

  xmlns:s="http://www.w3.org/2001/XMLSchema-instance"

  xmlns:y="http://www.w3.org/2001/XMLSchema"

  E:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<E:Body>

<m:checkVat

  xmlns:m="urn:ec.europa.eu:taxud:vies:services:checkVat:types">

<ns1:countryCode

  xmlns:ns1="urn:ec.europa.eu:taxud:vies:services:checkVat"

  s:type="y:string">BE</ns1:countryCode>

<ns2:vatNumber

  xmlns:ns2="urn:ec.europa.eu:taxud:vies:services:checkVat"

  s:type="y:string">0810416786</ns2:vatNumber>

</m:checkVat>

</E:Body>

</E:Envelope>

RESPONSE:

HTTP/1.1 500 Internal Server Error

Date: Wed, 04 Jun 2014 09:33:11 GMT

Transfer-Encoding: chunked

Content-Type: text/xml; charset=UTF-8

Server: Europa

Connection: Keep-Alive

Transfer is Chunked!

01d7

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Unmarshalling Error: unexpected element (uri:"urn:ec.europa.eu:taxud:vies:services:checkVat", local:"countryCode"). Expected elements are &lt;{urn:ec.europa.eu:taxud:vies:services:checkVat:types}vatNumber>,&lt;{urn:ec.europa.eu:taxud:vies:services:checkVat:types}countryCode> </faultstring></soap:Fault></soap:Body></soap:Envelope>

0000

GetChunkLength: 01d7 = 471

Connection Disconnected

SOAPLOG END

Now i tried the to cut and paste the above soap envelop in SOAPUI , and it gives me the exact same error message as in the soaplog.

I then tried creating a request through SOAPUI but based on the wdsl ,SOAPUI is giving me a different soap envelop as the one PB generated ?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:ec.europa.eu:taxud:vies:services:checkVat:types">

   <soapenv:Header/>

   <soapenv:Body>

      <urn:checkVat>

         <urn:countryCode>?</urn:countryCode>

         <urn:vatNumber>?</urn:vatNumber>

      </urn:checkVat>

   </soapenv:Body>

</soapenv:Envelope>

If i enter parameters in the above envelop and check it through SOAPUI , i end up having the result i want.

Is there any way we can manipulate the soap envelop contents ? Or does anyone have any idea why the soap envelop generated by PB ends up having the above mentioned error in the soaplog file ?

What am i missing ?

TIA

John

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member190719
Active Contributor
0 Kudos

You're using the EasySOAP proxy.  You didn't mention what version of PowerBuilder, but if you're using a version that supports the .Net engine instead use that.  The EasySOAP web service support is quite old.

Once you do that you won't be able to use the log.  Instead, use something like Fiddler to trap the request and response.