using zeep 3.4.0
wsdl is looking for the following information in header
<soapenv:Header>\n
<vv:sessionHeader soapenv:mustUnderstand=\"1\">\n
<vv:sessionToken>\n
<vv:Token1 xmlns:vv=\"http://www.z.com/zTypes.xsd\">{{Token1Token}}
</vv:Token1>\n
<vv:Token2 xmlns:vv=\"http://www.z.com/zTypes.xsd\">{{Token2Token}}
</vv:Token2>\n
</vv:sessionToken>\n
</vv:sessionHeader>\n
I am passing parameters to _soapheaders as follows
headerQ = xsd.Element('Header',xsd.ComplexType ([
xsd.Element('sessionHeader',xsd.ComplexType ([
xsd.Element('sessionToken', xsd.ComplexType ([
xsd.Element('Token1',xsd.String()),
xsd.Element('Token2',xsd.String())
]))
]))
]))
header_value1 = headerQ({'Token1':Token1T, 'Token2':Token2T} )
client.set_default_soapheaders(header_value1)
header_value1 looks like this
{
'sessionHeader': {
'Token1': 'abcdef=',
'Token2': 'ghijkl='
}
}
I get the following error:
line 365, in _serialize_header
raise ValueError("Invalid value given to _soapheaders")
_serialize_header expects header_value1 to be either a list or a dictionary
isinstance(header_value1,dict) returns False
Questions:
What is the correct way to pass parameters to _soapheaders
Why is sessionToken not reflected in the header
Debugging things with Zeep is always a bit of a challenge, but here's a working implementation:
In order to correctly render two elements (Token1 and Token2) you need a xsd:Sequence element:
headerQ = xsd.Element('Header', xsd.ComplexType([
xsd.Element('{http://www.z.com/zTypes.xsd}sessionHeader', xsd.ComplexType([
xsd.Element('{http://www.z.com/zTypes.xsd}sessionToken', xsd.ComplexType(
xsd.Sequence([
xsd.Element('{http://www.z.com/zTypes.xsd}Token1', xsd.String()),
xsd.Element('{http://www.z.com/zTypes.xsd', xsd.String())
])))
], attributes=[xsd.Attribute('mustUnderstand', xsd.Boolean())
]))
]))
Providing the QNames instead of raw element names will take care of the namespaces and finally you set the attributes on the sessionToken type definition. If your soap server refuses to accept "true" then you can use an xsd:Integer type, or you can rewrite "true" to "1" using an egress plugin as shown here
Setting the header value works as you tried, although you need to wrap into a list:
header_value1 = headerQ(
{'mustUnderstand': True,
'sessionToken': {'Token1': 'Token1T',
'Token2': 'Token2T'}
}
)
client.set_default_soapheaders([header_value1])
This gives the header section:
<Header>
<ns0:sessionHeader xmlns:ns0="http://www.z.com/zTypes.xsd" mustUnderstand="true">
<ns0:sessionToken>
<ns0:Token1>Token1T</ns0:Token1>
<ns0:Token2>Token2T</ns0:Token2>
</ns0:sessionToken>
</ns0:sessionHeader>
</Header>
rather than using the built in method, I got it working with
header_value1 = {'sessionHeader': {'sessionToken': { \
'primary': token1, secondary': token2}}}
Related
I'm working on switching OpenAPI v2 to Open API 3, we'll be using MicroProfile 2.0 with Projects as the plugin that will generate the OAS from the code.
Now, we have different headers that are needed as a kind of authorization. I know I can put them on each resource, that seems just a lot of repetition, so I thought it was a good idea to put in the JaxRSConfiguration file as a #SecurityScheme and add them as security to the #OpenApiDefinition.
#OpenAPIDefinition(
info = #Info(
...
)
),
security = {
#SecurityRequirement(name = Header1),
#SecurityRequirement(name = Header2)
},
components = #Components(
securitySchemes = {
#SecurityScheme( apiKeyName = Header1 ... ) ,
#SecurityScheme( apiKeyName = Header2 ....)
}),
...
)
This is working, however it generates an OR, while it should be an AND (without the - )
security:
- Header1: []
- Header2: []
I thought I could use #SecurityRequirementsSet inside security in the #OpenApiDefinition, but unfortunately this is not allowed. I know I can use it on each call or on top of the class of the different calls but as this is still a sort of repetition, I would prefer to have it as a general authentication security.
Does anybody know how I can achieve this ?
Warning! I am not a Java coder. I think I am missing the needed gene.
I have a Gatling call that captures a StateToken needed in authentication.
.exec(http("00_Access_Site_10")
// This exec captures the stateToken parameter
.get("https://sso-cert.johndeere.com/login/login.htm?fromURI=%2Fapp%2Fjohndeerecert_dealerpathcert_1%2Fexkcj9qb4cfudNvLR1t7%2Fsso%2Fsaml")
.header("Accept:", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3")
.header("Accept-Encoding:", "gzip, deflate, br")
.header("Accept-Language:", "en-US,en;q=0.9")
.header("Sec-Fetch-Site:", "none")
.header("Sec-Fetch-Mode:", "navigate")
.header("Sec-Fetch-User:", "?1")
.check(regex(""""(?<=stateToken":")(.*)(?=","help)""").saveAs("StateToken"))
//.check(bodyString.saveAs(key = "responseBody"))
)
This works, except in the StateToken string that is captured are characters that need to be converted, i.e. \2D needs to be a hyphen ("-").
This:
.check(regex(""""(?<=stateToken":")(.*)(?=","help)""").saveAs("StateToken"))
.transform("{StateToken}" => str.replace("\\x2D","-"))
Does not work.
Thanks.
transform takes a function with one single parameter which is the original extracted value and returns the transformed result. So the correct syntax is:
.transform(str => str.replace("\\x2D","-"))
Then, transform is not at the right place:
.check(
regex(""""(?<=stateToken":")(.*)(?=","help)""")
.transform(str => str.replace("\\x2D","-"))
.saveAs("StateToken")
)
I've read all the documentation I can find and watched all the videos I can find and don't understand how to do this. I have set up an xPages REST Service and it works well. Now I want to place the results of the service into either a combobox or typeahead text field. Ideally I would like to know how to do it for both types of fields.
I have an application which has a view containing a list of countries, another view containing a list of states, and another containing a list of cities. I would like the first field to only display the countries field from the list of data it returns in the XPages REST Service. Then, depending upon which country was selected, I would like the states for that country to be listed in another field for selection, etc.
I can see code for calling the REST Service results from a button, or from a dojo grid, but I cannot find how to call it to populate either of the types of fields identified above.
Where would I call the Service for the field? I had thought it would go in the Data area, but perhaps I've just not found the right syntax to use.
November 6, 2017:
I have been following your suggestion, but am still lost as can be. Here's what I currently have in my code:
x$( "#{id:ApplCountry}" ).select2({
placeholder: "select a country",
minimumInputLength: 2,
allowClear : true,
multiple: false,
ajax: {
dataType: 'text/plain',
url: "./Application.xsp/gridData",
quietMillis: 250,
data: function (params) {
return {
search:'[name=]*'+params.term+'*',
page: params.page
};
},
processResults: function (data, page) {
var data = $.map(data, function (obj) {
obj.id = obj.id || obj["#entityid"];
obj.text = obj.text || obj.name;
return obj;
});
},
return {results: data};
}
}
});
I'm using the dataType of 'text/plain' because that was what I understood I should use when gathering data from a domino application. I have tried changing this to json but it makes no difference.
I'm using processResults because I understand this is what should be used in version 4 of select2.
I don't understand the whole use of the hidden field, so I've stayed away from that.
No matter what I do, although my REST service works if I put it directly in the url, I cannot get any data to display in the field. All I want to display in the field is the country code of the document, which is in the field named "name" (not my choice, it's how it came before I imported the data from MySQL.
I have read documentation and watched videos, but still don't really understand how everything fits together. That was my problem with the REST service. If you use it in Dojo, you just put the name of the service in a field on the Dojo element and it's done, so I don't understand why all the additional coding for another type of domino element. Shouldn't it work the same way?
I should point out that at some points it does display the default message, so it does find the field. Just doesn't display the country selections.
I think the issue may be that you are not returning SelectItems to your select2, and that is what it is expecting. When I do something like you are trying, I actually use a bean to generate the selection choices. You may want to try that or I'm putting in the working part of my bean below.
The Utils.getItemValueAsString is a method I use to return either the string value of a field, or if it is not on the document/empty/null an empty string. I took out an if that doesn't relate to this, so there my be a mismatch, but I hope not.
You might be able to jump directly to populating the arrayList, but as I recall I needed to leverage the LinkedHashMap for something.
You should be able to do the same using SSJS, but since that renders to Java before executing, I find this more efficient.
For label/value pairs:
LinkedHashMap lhmap = new LinkedHashMap();
Document doc = null;
Document tmpDoc = null;
allObjects.addElement(doc);
if (dc.getCount() > 0) {
doc = dc.getFirstDocument();
while (doc != null) {
lhmap.put(Utils.getItemValueAsString(doc, LabelField, true), Utils.getItemValueAsString(doc, ValueField, true));
}
tmpDoc = dc.getNextDocument(doc);
doc.recycle();
doc = tmpDoc;
}
}
List<SelectItem> options = new ArrayList<SelectItem>();
Set set = lhmap.entrySet();
Iterator hsItr = set.iterator();
while (hsItr.hasNext()) {
Map.Entry me = (Map.Entry) hsItr.next();
// System.out.println("after: " + hStr);
SelectItem option = new SelectItem();
option.setLabel(me.getKey() + "");
option.setValue(me.getValue() + "");
options.add(option);
}
System.out.println("About to return from generating");
return options;
}
I ended up using straight up SSJS. Worked like a charm - very simple.
I have a requirement to convert the output of cypher into JSON.
Here is my code snippet.
RestCypherQueryEngine rcqer=new RestCypherQueryEngine(restapi);
String nodeN = "MATCH n=(Company) WITH COLLECT(n) AS paths RETURN EXTRACT(k IN paths | LAST(nodes(k))) as lastNode";
final QueryResult<Map<String,Object>> queryResult = rcqer.query(searchQuery);
for(Map<String,Object> row:queryResult)
{
System.out.println((ArrayList)row.get("lastNode"));
}
Output:
[http://XXX.YY6.192.103:7474/db/data/node/445, http://XXX.YY6.192.103:7474/db/data/node/446, http://XXX.YY6.192.103:7474/db/data/node/447, http://XXX.YY6.192.103:7474/db/data/node/448, http://XXX.YY6.192.103:7474/db/data/node/449, http://XXX.YY6.192.103:7474/db/data/node/450, http://XXX.YY6.192.103:7474/db/data/node/451, http://XXX.YY6.192.103:7474/db/data/node/452, http://XXX.YY6.192.103:7474/db/data/node/453]
I am not able to see the actual data (I am getting URL's). I am pretty sure I am missing something here.
I would also like to convert the output to JSON.
The cypher works in my browser interface.
I looked at various articles around this:
Java neo4j, REST and memory
Neo4j Cypher: How to iterate over ExecutionResult result
Converting ExecutionResult object to json
The last 2 make use of EmbeddedDatabase which may not be possible in my scenario (as the Neo is hosted in another cloud, hence the usage of REST).
Thanks.
Try to understand what you're doing? Your query does not make sense at all.
Perhaps you should re-visit the online course for Cypher: http://neo4j.com/online-course
MATCH n=(Company) WITH COLLECT(n) AS paths RETURN EXTRACT(k IN paths | LAST(nodes(k))) as lastNode
you can just do:
MATCH (c:Company) RETURN c
RestCypherQueryEngine rcqer=new RestCypherQueryEngine(restapi);
final QueryResult<Map<String,Object>> queryResult = rcqer.query(query);
for(Node node : queryResult.to(Node.class))
{
for (String prop : node.getPropertyKeys()) {
System.out.println(prop+" "+node.getProperty(prop));
}
}
I think it's better to use the JDBC driver for what you try to do, and also actually return the properties you're trying to convert to JSON.
I am new to extbase(MVC) Framework , How can we get typoscript values in our extension :
Eg : suppose if i have some typoscript values like:
plugin.tx_some-extname.somevlaueX = XXXX
plugin.tx_some-extname.somevlaueY = yyyy
plugin.tx_some-extname.somevlaueZ = zzzz
how will i get these values in a specific action of our controller .I hope this makes sense ??
Declare values in the settings scope (in the setup field) ie:
plugin.tx_some-extname.settings {
myXsetting = XXXX
}
So the all settings will be accesible in your plugin in $this->settings (as array) :
$valX = $this->settings['myXsetting'];
In TYPO3-7.6 + the whole TypoScript for an extension can be retrieved with
$typoScript = $this->configurationManager->getConfiguration( $this->configurationManager::CONFIGURATION_TYPE_FRAMEWORK);
where for the 1st parameter exist 3 different options:
$this->configurationManager::CONFIGURATION_TYPE_SETTINGS
$this->configurationManager::CONFIGURATION_TYPE_FRAMEWORK
$this->configurationManager::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
optional for the function $this->configurationManager->getConfiguration() the extension-key can be given as 2nd parameter and the plugin-name as 3rd parameter. So the whole command looks like this:
$typoScript = $this->configurationManager->getConfiguration( $this->configurationManager::CONFIGURATION_TYPE_FRAMEWORK, $extensionKey, $pluginName );
Consider that the static template has to be included in the backend-template to return the desired output.
ConfigurationManager is an instance of
TYPO3\CMS\Extbase\Configuration\ConfigurationManager