In an angularjs application I am making a call to a REST service that returns an octet-stream. The content of the stream is a xml file, that I want to get the content of and then pass onto another control. This works fine in Chrome and Firefox but in IE (I have 11, but also saw this in Edge) the content returned looks like garbage (actually a bunch of chinese characters) when I debug through IE Developer tools, and the subsequent control fails because it is expecting xml.
<resource path="/{type}/{modelName}">
<param name="type" style="template" type="xs:string"/>
<param name="modelName" style="template" type="xs:string"/>
<method name="POST">
<request>
<representation mediaType="text/plain">
<param name="request" style="plain" type="xs:string"/>
</representation>
</request>
<response>
<representation mediaType="application/octet-stream"/>
</response>
</method>
</resource>
And the call looks like:
Restangular.one('streams/graphML/' + model.name + '?maxNodes=1000').withHttpConfig(config).get().then(function (response) {
callback({error: false, data: response});
},
function (response) {
spectrumSdkLog.error(response.data);
callback({error: true, message: response.data});
});
Any help with why this is would be greatly appreciated. I have been looking for an answer but have yet to find one.
Thanks
Related
Working with a SOAP API in React JS and all is fine except for this one function keeps returning a 400 error.
Using Axios to make the POST request with the following syntax.
The goal is to obtain a specific client ID and be able to edit specified fields.
let getExtraInfo = `<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<UpdateClientAdditionalFields xmlns="http://www.ozsoft.com.au/VETtrak/api/complete">
<token>${token}</token>
<clientCode>09224</clientCode>
<additionalFieldData>
<AdditionalData>
<Gender>M</Gender>
</AdditionalData>
</additionalFieldData>
</UpdateClientAdditionalFields>
</soap:Body>
</soap:Envelope>`
Here is a link to the API
https://sthservices.ozsoft.com.au/SIU_API/VT_API.asmx?op=UpdateClientAdditionalFields
I have tried every combination to get the request to work correctly but I believe the issue may be to incorrect syntax on the API end.
For reference here is my API call using Axios.
async function GetTimetableData(xmlsChosen){
const response = await axios.post('https://thingproxy.freeboard.io/fetch/https://sthservices.ozsoft.com.au/SIU_API/VT_API.asmx?wsdl',
xmlsChosen,
{
headers:{
'Content-Type': 'text/xml'}
}).then(res=>{
var jsonObj = parse(res.data);
// setCourseChosen(jsonObj.["soap:Envelope"]["soap:Body"].GetOccurrenceExtendedDetailsResponse.GetOccurrenceExtendedDetailsResult.OccuExtended);
console.log(jsonObj);
}).catch(err=>{console.log(err);
}).finally(() => {
});
}
Would anyone be able to provide some insight as to how to do this request using React JS. I have asked the devs directly but their responses are in PHP and doesn't help with this specific issue.
The list of additional fields can also be found here.
https://customer.vettrak.com.au/hc/en-us/articles/360002285835
I can provide more information if needed.
UPDATE
I have added the headers and checked that the token is correct - I also don't have issues making other requests with the token with other functions.
I have tried the syntax below.
`<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://www.ozsoft.com.au/VETtrak/api/complete">
<soap:Body>
<com:UpdateClientAdditionalFields>
<com:token>676767676</com:token>
<com:clientCode>09224</com:clientCode>
<com:additionalFieldData>"<com:AdditionalData><com:Gender>M></com:Gender></com:AdditionalData>"</com:additionalFieldData>
</com:UpdateClientAdditionalFields>
</soap:Body>
</soap:Envelope>`
`<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://www.ozsoft.com.au/VETtrak/api/complete">
<soap:Body>
<com:UpdateClientAdditionalFields>
<com:token>${token}</com:token>
<com:clientCode>09224</com:clientCode>
<com:additionalFieldData><AdditionalData><Gender>M><Gender><AdditionalData></com:additionalFieldData>
</com:UpdateClientAdditionalFields>
</soap:Body>
</soap:Envelope>`
If I do the following request
`<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://www.ozsoft.com.au/VETtrak/api/complete">
<soap:Body>
<com:UpdateClientAdditionalFields>
<com:token>${token}</com:token>
<com:clientCode>09224</com:clientCode>
<com:additionalFieldData><com:AdditionalData>string</com:AdditionalData></com:additionalFieldData>
</com:UpdateClientAdditionalFields>
</soap:Body>
</soap:Envelope>`
I get a "A problem occurred when parsing the additional data XML: Data at the root level is invalid. Line 1, position 1." Error. I know the token and client code are fine as when I don't include them I get an Authentication Error / Client doesn't exist response.
Then when I do:
`<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://www.ozsoft.com.au/VETtrak/api/complete">
<soap:Body>
<com:UpdateClientAdditionalFields>
<com:token>${token}</com:token>
<com:clientCode>09224</com:clientCode>
<com:additionalFieldData><com:AdditionalData><gender>M</gender><com:/AdditionalData></com:additionalFieldData>
</com:UpdateClientAdditionalFields>
</soap:Body>
</soap:Envelope>`
I get the usual 400 error.
After looking at the UpdateClientAdditionalFields inside the WSDL, it seems one of your parameters is wrong. The top element is defined as:
<s:element name="UpdateClientAdditionalFields">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="token" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="clientCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="additionalFieldData" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
additionalFieldData is a string, but you are sending an XML in your message:
<additionalFieldData>
<AdditionalData>
<Gender>M</Gender>
</AdditionalData>
</additionalFieldData>
Try with a string or without this field just to see if it works (since it is optional minOccurs="0").
Also, your token may be wrong:
<token>${token}</token>
Is this a variable that you need to replace before the call?
Add also a HTTP header named SOAPAction like this:
SOAPAction: "http://www.ozsoft.com.au/VETtrak/api/complete/UpdateClientAdditionalFields"
Try again with these changes and see if it works.
EDIT based on comments:
Are you sending proper values for the token, clientCode, and additionalFieldData elements? I mean actual, usable values, all of type string, not placeholders like ${token} or XML elements instead of string values?
Your SOAP request should look like this (don't forget to add the SOAPAction HTTP header):
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://www.ozsoft.com.au/VETtrak/api/complete">
<soap:Body>
<com:UpdateClientAdditionalFields>
<com:token>proper value here</com:token>
<com:clientCode>proper value here</com:clientCode>
<com:additionalFieldData>proper value here</com:additionalFieldData>
</com:UpdateClientAdditionalFields>
</soap:Body>
</soap:Envelope>
I am writing an xml file in klish. I want to know how can we auto complete an parameter by pressing tab button in klish xml files. For E.g. I want user to enter either enable or disable on klish command line but if user press 'e' and tab then automatically enable should be completed or if user presses 'd' and tab then automatically disable should come.
I am receiving these parameter on klish command line by user.
And also can we define macros in klish xml files so that i can use that macro in klish ACTION tag to pass that macro value as a parameter to my c file
My XML code is like this :-
<?xml version="1.0" encoding="UTF-8"?>
<CLISH_MODULE xmlns="http://clish.sourceforge.net/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://clish.sourceforge.net/XMLSchema
http://clish.sourceforge.net/XMLSchema/clish.xsd">
<!--=======================================================-->
<COMMAND name="show"
help="some utility commands for show"/>
<COMMAND name="show connection"
help="Show the connection">
<DETAIL>
connection status
</DETAIL>
<ACTION>c_file.c 1</ACTION>
</COMMAND>
<COMMAND name="show debugcount"
help="It will show enable core">
<DETAIL>
Enable core.
</DETAIL>
<PARAM name="module-name"
help="Specify the module name i.e. enable or disable"
ptype="STRING"/>
<ACTION>c_file.c 3 ${module-name}</ACTION>
</COMMAND>
As I mentioned that I want auto complete of a statement so the parametere i.e.
${modulename}
will be either enable or disable so I want if user press e and tab then automatically enable should come or if user press d and tab then automatically disable should be come.
And about macros as you can see in tag I am passing value i.e.
<ACTION>c_file.c 1</ACTION>
to my c file but instead of value I want to use some variable name or macro so it would be something like
<ACTION>c_file ${var} ${modulename}</ACTION>
where $var=1
After lot of research finally I successfully implemented auto completion of command.
Like in my example I want user to enter enable or disable in command line. This can be achieved by the following xml file. Just we had to use VAR tag in xml file and same for macros.
<?xml version="1.0" encoding="UTF-8"?>
<CLISH_MODULE xmlns="http://clish.sourceforge.net/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://clish.sourceforge.net/XMLSchema
http://clish.sourceforge.net/XMLSchema/clish.xsd">
<!--=======================================================-->
<COMMAND name="show"
help="some utility commands for show"/>
<COMMAND name="show connection"
help="Show the connection">
<DETAIL>
connection status
</DETAIL>
<ACTION>c_file.c 1</ACTION>
</COMMAND>
<COMMAND name="show debugcount"
help="It will show enable core">
<DETAIL>
Enable core.
</DETAIL>
<PARAM name="module-name"
help="Specify the module name i.e. enable or disable"
ptype="STRING"
completion="${third_par}"/>
<ACTION>c_file.c 3 ${module-name}</ACTION>
<VAR name="third_par" help="enable/disable" value="enable disable"/>
</COMMAND>
About completion. There are several ways to implement it.
The first way is something like this:
<PARAM name="module-name"
help="Specify the module name i.e. enable or disable"
ptype="STRING"
completion="enable disable"/>
It's simple but not strict i.e. user can type something else than "enable/disable".
The second way is PTYPE with method="select":
<PTYPE name="BOOL" method="select" pattern="true(1) false(0)" help="Boolean choice"/>
This way is strict. Autocompletion will show "true/false" but user will get corresponding PARAM with values "1/0" in ACTION. But you can use pattern="true(true) false(false)" to get "true" or "false" in ACTION.
The third way is switch:
<PARAM name="choose" help="switch example" mode="switch" ptype="SWITCH">
<PARAM name="enable" help="Enable" ptype="SUBCOMMAND" mode="subcommand"/>
<PARAM name="disable" help="Disable" ptype="SUBCOMMAND" mode="subcommand"/>
</PARAM>
It's strict. The user must choose (enter) only one of PARAMs inside "switch" PARAM.
About VARs... The VARs in klish is global. So it can appear without COMMAND tag or VIEW tag. Put it on the same level as "VIEW" tag.
I am not sure if the above XML is well-formed. It seems that in the current clish.xsd schema the <VAR> element is no longer valid to be under the <COMMAND> element. In fact, the <VAR> element has no valid place at all.
To verify: xmllint -schema /path/to/latest/clish.xsd --noout /path/to/your/file.xml
You will notice that the presence of the <VAR> will invalidate the XML against the schema.
Below is the <COMMAND> element schema:
<xs:complexType name="command_t">
<xs:sequence>
<xs:element ref="DETAIL" minOccurs="0"/>
<xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="CONFIG" minOccurs="0"/>
<xs:element ref="ACTION" minOccurs="0"/>
</xs:sequence>
<xs:attributeGroup ref="menu_item_g"/>
<xs:attribute name="ref" type="xs:string" use="optional"/>
<xs:attribute name="view" type="xs:string" use="optional"/>
<xs:attribute name="viewid" type="xs:string" use="optional"/>
<xs:attribute name="access" type="xs:string" use="optional"/>
<xs:attribute name="args" type="xs:string" use="optional"/>
<xs:attribute name="args_help" type="xs:string" use="optional"/>
<xs:attribute name="escape_chars" type="xs:string"
use="optional"/>
<xs:attribute name="lock" type="bool_t" use="optional"
default="true"/>
<xs:attribute name="interrupt" type="bool_t" use="optional"
default="false"/>
</xs:complexType>
Basically, specifying that inside COMMAND should be in order the following:
DETAIL
PARAM
CONFIG
ACTION
So if you place DETAIL after PARAM, it is invalid against the schema. I am referring to the following clish.xsd schema version in klish git repo:
Author: Serj Kalichev <serj.kalichev#gmail.com>
Date: Fri Dec 15 18:03:53 2017 +0300
Version 2.1.4
Not wanting to clog up the question, I've left out most of the code but I can put it in if it helps.
using Breeze 1.4.9 and Breeze.angular v.0.9.0
I have a simple model: a ChartDefinition has a single DataQuery, and that DataQuery has some parameters.
I have a breeze query:
var query = breeze.EntityQuery
.from("ChartDefinitions")
.expand(["DataQuery","DataQuery.Parameters"]);
//.noTracking();
I can see the server's response (i've replaced most of the simple properties with '...'):
[{"$id":"1","$type":"itaprm4.Domain.ChartDefinition, itaprm4","Id":1,"Title":"FirstChart", ... ,
"DataQuery":
{"$id":"2","$type":"itaprm4.Domain.DataQuery, itaprm4","Id":1, ... ,
"Parameters":
[{"$id":"3","$type":"itaprm4.Domain.DataQueryParameter, itaprm4","Id":1, ...}]
}
}
,{"$id":"4","$type":"itaprm4.Domain.ChartDefinition, itaprm4","Id":2,"Title":"ProjectBudgets", ... ,
"DataQuery":
{"$id":"5","$type":"itaprm4.Domain.DataQuery, itaprm4","Id":2, ... ,
"Parameters":[]
}
},
{"$id":"6","$type":"itaprm4.Domain.ChartDefinition, itaprm4","Id":3,"Title":"ProjectActuals", ... ,
"DataQuery":
{"$id":"7","$type":"itaprm4.Domain.DataQuery, itaprm4","Id":3, ... ,
"Parameters":
[{"$id":"8","$type":"itaprm4.Domain.DataQueryParameter, itaprm4","Id":2,"DataQueryId":3, ...},
{"$id":"9","$type":"itaprm4.Domain.DataQueryParameter, itaprm4","Id":3,"DataQueryId":3, ...}
]
}
}]
After the entities have been materialised though, that last DataQuery object ($id:7) has a parameters array but, it only contains the last parameter ($id:9).
Digging around in breeze.debug I saw that noTracking causes the materialisation code down a different path so tacked the noTracking() option onto the query. This results in both the paramters appearing in the materlised Parameters array. (I'm assuming that since breeze can materialise the object graph correctly, there isn't anything wrong with the code on the server? so I haven't included it in this question...)
I would simply keep the noTracking option on but, I'm registering a constructor function with breeze and it doesn't get called if noTracking is on.
store.registerEntityTypeCtor('ChartDefinition', ChartDefinition);
Is there something else I need to do to get the parameters array filled without the noTracking option?
Edit:
Another observation : without the noTracking option, the DataQueryParameter with $id:8 actually ends up in the parameters array of the DataQuery with $id:5
Turns out this had a lot to do with what was on the server!
Our nHibernate set-up was using a different name for the DataQueryId property on the DataQuery class (the devs in the team tell me there were some issues with updating entities and doing this solved that issue):
<class name="DataQuery" table="sys_DataQuery" dynamic-update="true" >
<id name="Id" column="DataQueryId" type="int" unsaved-value="0">
<generator class="identity" />
</id>
...
<bag name="Parameters" cascade="all-delete-orphan">
<key column="DataQueryId"/>
<one-to-many class="DataQueryParameter"/>
</bag>
</class>
<class name="DataQueryParameter" table="sys_DataQueryParameter" dynamic-update="true" >
...
<property name="DataQueryId" type="int" not-null="true" insert="true" update="true" />
...
</class>
With matching identifiers in the class definitions.
Changing the Id to DataQueryId solved my problem:
<class name="DataQuery" table="sys_DataQuery" dynamic-update="true" >
<id name="DataQueryId" column="DataQueryId" type="int" unsaved-value="0">
<generator class="identity" />
</id>
...
This seems to make sense; how would breeze know to match DataQueryParamter.DataQueryId to DataQuery.Id but, I have no idea why Breeze could correctly materialise the object graph with noTracking switched on though?
#InInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingInInterceptor" )
#OutInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingOutInterceptor")
public class SKTWeb implements SKTWebService {
// method logic goes here
}
Hi , after adding these two lines inside the CXF Method Implementation .
I could get whip of SOAP Requestand Response under tomcat server console
see a instance of SOAP Request Printed under Tomcat console
INFO: Inbound Message
----------------------------
ID: 1
Address: /Sktweb-33.0/services/SKTWeb
Encoding: UTF-8
Content-Type: text/xml; charset=UTF-8
Headers: {cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[local
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns4:strategy xmlns:ns
Could anybody please tell me how can get this inside my Log file (Log4j)
Currently this is my log4j.properties file
log4j.rootCategory=INFO, A1
# A1 is a DailyRollingFileAppender
log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A1.file=/Haieeee.log
log4j.appender.A1.datePattern='.'yyyy-MM-dd
log4j.appender.A1.append=true
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-22d{dd/MMM/yyyy HH:mm:ss} - %m%n
And also i have META-INF\cxf\org\apache\cxf\Logger Log4jLogger.class inside the Web Application .
And also i kept
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
Inside the endpoints.xml file
Any help please
A slight bit of confusion it seems. You need your assembled application to have a locatable file META-INF/cxf/org.apache.cxf.Logger (yes, those are dots! It's not a .java or .class file) and it should have the contents:
org.apache.cxf.common.logging.Log4jLogger
I use exactly the above in my code and it works like a charm. (I don't use it with the message logging feature though; too much traffic when deployed for my tasteā¦)
Basically you want your properties file to be picked by CXF then it use this properties file instead of CXF's.
I am using spring configuration in my CXF application. If you are not using any Spring config then you create a new config and load it on start up using spring context listener, then you can add the below code in your XML file.
<bean id="log4jInitialization"
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="org.springframework.util.Log4jConfigurer" />
<property name="targetMethod" value="initLogging" />
<property name="arguments">
<list>
<value>file:fullpath/filename.properties</value>
</list>
</property>
</bean>
You can also have classpath:filename.properties in the <list> </list>. The logging implemented in Spring framework will be used to log all the request and response. You can also use the same logging implementation to use in your application.
Always go with interceptors...Add slf4j-log4j12-1.6.1.jar,slf4j-api-1.6.1.jar and commons-logging-1.1.1.jar. Paste the following code in your cxf.xml...
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor" id="loggingInInterceptor" />
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" id="logOutInterceptor" />
<cxf:bus>
<cxf:inInterceptors>
<ref bean="loggingInInterceptor" />
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="logOutInterceptor" />
</cxf:outInterceptors>
</cxf:bus>
I am using execAndWait interceptor and it seems the session is lost after the interceptor..
my code is - struts-lcms.xml
...
<action name="testAction" class="com.lcms.presentation.TestAction">
<interceptor-ref name="execAndWait"></interceptor-ref>
<param name="delay">3000</param>
<param name="delaySleepInterval">50</param>
<result name="wait" type="tiles">tiles.ques</result>
<result name="success" type="tiles">tiles.ques</result>
<result name="diag" type="redirectAction">diagnosticAction</result>
</action>
...
If I remove the interceptor code then it takes me to the question page (tiles.ques) .. However, with the interceptor the session is null..
This code in execute method in the TestAction file
SessionObject sess = (SessionObject)getSession().getAttribute(LcmsConstants.SESSION_OBJECT);
it gives the session correctly if the interceptor is not used.. however, if the interceptor code is used then it throws NULL pointer exception..
Please tell me how to overcome this problem..
implements SessionAware
http://struts.apache.org/2.0.6/struts2-core/apidocs/org/apache/struts2/interceptor/ExecuteAndWaitInterceptor.html
Important: Because the action will be running in a seperate thread, you can't use ActionContext because it is a ThreadLocal. This means if you need to access, for example, session data, you need to implement SessionAware rather than calling ActionContext.getSesion().
mention in struts.xml as
<interceptor-stack name="loadingStack">
<interceptor-ref name="completeStack" />
<interceptor-ref name="execAndWait">
<param name="delay">1000</param>
<param name="delaySleepInterval">500</param>
</interceptor-ref>
</interceptor-stack>
<interceptor-ref name="loadingStack"/>
<result name="wait">ETAX/TDS/wait.jsp</result>
it is working fine on my machine