I have a SOAPUI project aimed at v4 of an API. To use the API, I need to authenticate to get a token, and then use that token in subsequent API calls. I'm using a Property Transfer to pick up the authentication token and store it as a Custom Property (against the TestSuite). This all works fine.
I'm now working against v1 of the API, and I am trying to follow the same approach. However, when I do the token transfer, I get an error:
[Error: Unexpected element: CDATA]
The response from the v1 Authenticate request is near-identical, except for the following:
The returned elements have an initial capital
One of the namespaces is different (references version 1.0 rather than 4.0, as expected)
Content-Length header is 300 rather than 302 (can't see an actual difference in length though)
And there is no CDATA element within.
Sample Response:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<AuthenticateResponse xmlns="http://cse-healthcare.com/API/1.0">
<AuthenticateResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<AuthenticationToken>a183577c-52d8-4fa0-a73a-611e6a143d79</AuthenticationToken>
<Response xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
<Status>
<Code>EGE00</Code>
<Description i:nil="true"/>
<Status>OK</Status>
</Status>
</AuthenticateResult>
</AuthenticateResponse>
</s:Body>
</s:Envelope>
Property Transfer:
I'm using //*:AuthenticationToken/text(), which is identical to that working against v4, apart from the initial capital.
It's not an absolute show-stopper; I don't have that much testing to do so copying the token to other requests would not be crippling, but it is just frustrating that something that appears to be identical does not work.
Any ideas?
The property transfer step targets children of a node in the XML. If the specified node does not contain any children, then the text node will be selected. If there are additional children, then the resulting hierarchy will be selected. In either case you can restrict that only the text be transferred, by selecting the "Transfer text content" option.
Additional documentation is here.
For your case, removing the /text() node from your XPath should work.
Related
We are creating the server side for a SOAP based service that uses MTOM/XOP to receive binary files (zip).
The xsd for the service has the following element definition for the binary file:
<xs:element name="thebinaryfile" type="xs:hexBinary" xmime:contentType="application/octet-stream"/>
We have been using the same approach as demo'ed here (but without all the repository classes etc):
https://github.com/spring-projects/spring-ws-samples/tree/main/mtom/server
The issue is that when the type "hexBinary" is used, the get'er on the generated request object always returns null. If we change the type to "base64Binary", we get the proper value populated in the byte array.
We send identical requests from SoapUI and see that they reaches the server as expected. But something happens on the receiving side when the libraries are trying to populate the request objects when usng "hexBinary".
Any ideas? Is there no support for hexBinary in MTOM/XOP?
I'm trying to extract the CSRF token so I can log in, and be able to obtain cookies, but I'm not able to.
I'm able to get a 200 response code when accessing the URL that contains the CSRF token, and I'm able to see it on the browser and the console, but my response assertion is not able to assert anything regardless of me changing the apply to, field to test, and pattern matching rules sections. My regular expression extractor isn't able to get anything either. All the headers to get to the URL are there. Any suggestions?
Forgot to mention, I'm able to get it on one server that's exactly (or should be) exactly the same as this one...
EDIT:
I placed it under the HTTP Sampler that has that response, and here is an example of what I get for my response assertion. I've also added various images.
Unfortunately you didn't share your output, so I cannot tell for sure, but although it seems your RegEx is correct in both cases, it could be that it doesn't match due to some extra spacing.
It appears that you are expecting a valid JSON, so instead of RegEx you could use JSON Extractor and/or JSON Assertion, for which extra spacing will not matter.
Example: if Response Data is
{"token":"12345"}
I can specify JSON Extractor as
(most important line is JSON Path: $.token)
and the result will be variable token with value 12345.
Here's a good online JSON Path tester, which can help you to figure out the right JSON Path.
If your goal is to check presence of a JSON Object with name of token and an arbitrary value I would recommend going for JSON Assertion instead.
Add JSON Assertion as a child of the request you would like to assert.
Use the following JSON Path query:
$.token
JSON Assertion is available since JMeter 4.0
If you still want to go for the Response Assertion - configure it as follows:
Pattern Matching Rules: Contains
Patterns to Test: {"token":"(.+?)"}
I want to send a POST request on Google Contacts API. It works well at the moment.
But I wonder why I get a 400 Bad Request Error if I don't specify a phone number.
<?xml version="1.0" encoding="UTF-8"?>
<errors xmlns="http://schemas.google.com/g/2005">
<error>
<domain>GData</domain>
<code>invalid</code>
<internalReason>Phone number must not be empty</internalReason>
</error>
</errors>
If someone knows if I can bypass it ?
Notice that when you add a contact on Google Contacts, there's not this restriction.
You're getting that error because it's stated in the docs that these extension elements need to be provided a rel attribute or a label attribute:
In the Contacts Data API, several elements are slightly more
restrictive than indicated in the documentation for the Contact kind.
In particular, a client must supply either a rel attribute or a label
attribute, but not both, for the following elements:
gd:email gd:im gd:organization gd:phoneNumber gd:postalAddress
In short, you really need to provide the phone number.
In my application I have to consume a service provided by a third party application. The response they provide is always 200 and they change the body based on whether data is available or not or error occurred, as given below
If data is there then
<products>
<product></product>
<product></product>
</products>
If data is empty then
<message> No record found </message>
If some validation failed then
<error>Invalid Id</error>
I am using RestTemplate.exchange to consume the service, my question is if there only single type of root element then we pass the respective class as ParameterizedTypeReference but here how to map the response and unmarshall it.
Use jaxb or jackson to unmarshall the xml.
The right thing to do here is to ask the third party to change their service response to have a root tag. The response object would then look something like this:
<response>
<products>
<product></product>
<product></product>
</products>
<message> No record found </message>
<error>Invalid Id</error>
</response>
With this, you will only need to be concerned about response object and you can check the presence of respective sub-tags.
Other option to make this work for you is to do the exchange by passing String.class as the type reference. Then you would need to do the check in your code to see if the string response returned is products or message or error
I am using JMeter to do load-testing. My test consists of a simple POST request. When I perform this request, the server, in its error logs, says No Payload Detected. I have verified that the server is receiving a Post request, and I have tried different texts in the Raw Post Body.
Next, to make sure it wasn't a problem with the server, I used a different Http Request program (Wiztools rest client) to send off a post with the same content. It works, and no No Payload Detected error is thrown.
My current theory is that both JMeter and the server do parsing. I know the server does, as it is looking for a small piece of data, and that JMeter's parsing ruins that small piece of data.
So, in conclusion, my question is "What parsing does JMeter do?".
I've looked for this answer, and the only thing I know that it does parse is ${VARNAME}.
The text I am sending is below:
<IpReport xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="">
<ProductReviewId>12345</ProductReviewId>
<DepartmentCode>ABC</DepartmentCode>
<ProductTitle>Test of a teaser</ProductTitle>
<ProjectId>2</ProjectId>
<ProductCodePD>ICS-1139150</ProductCodePD>
<Priority>Pre-Approved</Priority>
<Status>Approved</Status>
<IpStatus>Submitted</IpStatus>
<EvalStatus>Approved</EvalStatus>
<EvalNotes>No Limitations - message from eval</EvalNotes>
<Notes>Notes test</Notes>
<IsInClarity>true</IsInClarity>
<IsPreRelease>true</IsPreRelease>
<IsApproved>true</IsApproved>
<IsCOREvalIP>false</IsCOREvalIP>
<Elements>
<IpReportElement>
<IpReportElementLineItemId>21774</IpReportElementLineItemId>
<ElementType>ReportingStatement</ElementType>
<Contributor>Sample Contributor</Contributor>
<Description>test</Description>
<LocationInProduct>test</LocationInProduct>
<ReportingStatementId>7</ReportingStatementId>
<IpCodeId>3</IpCodeId>
<Links>
<IpReportLink>
<IpReportLinkId>25982</IpReportLinkId>
<Name>Link</Name>
<Url>https://example.org/</Url>
</IpReportLink>
</Links>
</IpReportElement>
</Elements>
<CustomData><site>ldsorg</site>
<site-root>/preview/ldsorg/</site-root>
<correlation-document-id>123456-eng</correlation-document-id>
<post-to-server>l12773:9239</post-to-server>
</CustomData>
<ApprovalNumber>2013-1139150-I</ApprovalNumber>
<EvalApprovalNumber>2013-1139150-E</EvalApprovalNumber>
</IpReport>
Here is an screenshot of JMeter. This is the only request, with no other config elements:
You may also need to add an HTTP Header Manager as a child of HTTP Request to set some header like content-type:
First of all. In your question above, both in screenshot and in request text part of request has symbols < and > encoded and part - not. And you are using Content Encoding = UTF-8 in addition. Seems that in this situation request will be sent malformed.
You can add e.g. View Results Tree listener and check how the request is sent from jmeter.
You can try dedicated REST Sampler as well.