Ask a Question

TestComplete: Adding headers to Message bug?

pkolcon
New Contributor

TestComplete: Adding headers to Message bug?

Hi,

 

I'm trying to test my WebServices over net.tcp protocol, so I've choosen TestComplete to get it done.

 

I do not want to create XML files manually, so I'm using simple call to service methods. Most of them need custom header with authorization details, so I've attached to OnWebServiceRequest method, and using 

 

WebServiceHelperObj.AddHeader(NameNamespaceValue)

 

method I'm trying to get it done. Now,the problem:

 

After using the method mentioned above, my header does not look like it should. An example:

 

Calling : 

Helper.AddHeader("UserID", "http://tempuri.org/", "jsmith");

Helper.AddHeader("Password", "http://tempuri.org/", "25jeL3n");

 

results in header:

 

<s:Header>
  <a:Action s:mustUnderstand="1">http://tempuri.org/MethodContract/MethodName</a:Action>
  <a:MessageID>urn:uuid:9244f15d-ae34-422c-ad9d-cd32f616b042</a:MessageID>
  <a:ReplyTo>
         <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<UserID xmlns="http://tempuri.org/">
        <UserID>jsmith</UserID>
</UserID>
<Password xmlns="http://tempuri.org/">
      <Password>25jeL3n</Password>
</Password>
<a:To s:mustUnderstand="1">net.tcp://ADDRESS.svc</a:To>
</s:Header>

 

As you can see, the header elements are nested, which is not the result I would want to achieve.

 

Second problem: the header i require to add is nested structure, as follows:

 

<s:Header>

    <MyHeader>

       <UserName>NAME</UserName>

       <Password>Password</Password>

    </MyHeader>

</s:Header>

 

how can I achieve this using AddHelper method?

8 REPLIES 8
TanyaYatskovska
SmartBear Alumni (Retired)

Hi Pkolcon,

 

I would recommend that you submit a support case to investigate this behavior. You can reach out to them here: http://support.smartbear.com/product-list/

 

Also, I suggest that you take a look at other our API testing product – SoapUI NG. Perhaps, it will better match your needs. You can find more information about the product here:

https://smartbear.com/product/ready-api/soapui-ng/overview/

 

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



Hello and thanks for the reply,

 

As you might notice, the requirement for communication with Service is using net.TCP protocol. Does SoapUI NG Pro support it? Because, when I was searching for the informations about it, I couldn't find any confirmation - more than that, I've seen that previous version of SoapUI had no support for net.TCP. 

 

So, will SoapUI NG Pro be a better solution in my case? 

icenamor
Occasional Contributor

Hi, 

I try to reproduce the same code as appear https://support.smartbear.com/testcomplete/docs/app-testing/web/services/custom-headers.html 

 

1) I add a General event -> GeneralEvents_OnWebServiceRequest

2) Generate the script in python 

def GeneralEvents_OnWebServiceRequest(Sender, Request, Helper, RequestInfo): 


Helper.AddHeader('USER', 'http://auth.', '1014531');
Helper.AddHeader('PASSWORD', 'http://auth', '4QrcOUm6Wau+VuBX8g+IPg==');

 

def Main():

   webservice.example.method()

 

and the solution is: no head included and when I run the method GeneralEvents_OnWebServiceRequest appear:

AttributeError: 'NoneType' object has no attribute 'AddHeader'      14:25:40          Normal                                   0,00

Run Script Routine     Unit1 - GeneralEvents_OnWebServiceRequest      ...         Runs a script routine.

 

 

icenamor
Occasional Contributor

A recursive call to the keyword test has been detected.

 

tristaanogre
Esteemed Contributor

Based upon what you have posted, it appears that you have added the event handler as a script routine call to a keyword test.  That is not how event handlers work.  You should be running ONLY what you have declared as def Main().  The event handler will be triggered automatically when the request is made.  This is why you're getting the error your getting: there is no "Helper" to add a header to because you're running the event handler directly.

As for the recursive call... You probably have the keyword test you're trying to run call a method which in turn calls the keyword test.  That's what recursion is... Especially if you are having the keyword test call the event handler and the event handler calling Main which triggers the event handler.

The solution in the article you linked only runs "Main".  No other code is directly executed.

 

If you need further help, please post a screenshot of the KeywordTest you are attempting to run so we can help you correct that.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
icenamor
Occasional Contributor

The recursive problem is solved. The link for the code was not correct, however the problem with not type is not solved.

Here attach the problem. I hide the confidence data for my company.  I tested the data with SoaPUI and the webservice with this data is working. Problem.png

tristaanogre
Esteemed Contributor

Here's my guess....  That somehow, something is erroring before the OnWebServiceRequest event is being triggered that is causing the Helper object to not be instantiated.

 

I'm curious as to what the "Request" body is when you're in that OnWebServiceRequest.  It's possible that the request itself is not being generated properly... 

 

I'd drop a breakpoint on "Log.Message('start header')" and then, with the execution paused, investigate "Request" and see what's actually in there.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
icenamor
Occasional Contributor

Yes, the problem is causing the Helper object to not be instantiated. It is something does not appear in the tutorial. I have another problem now. 

Thanks for the help.

 

cancel
Showing results for 
Search instead for 
Did you mean: