My Endpoint is a Address Endpoint. The response contentType is "text/plain". And the reponse content is:
<message>
<header>
<TransactionID>1</TransactionID>
<Timestamp>2012-06-04 10:45:35</Timestamp>
<OpCode>AAA_Response</OpCode>
<MsgType>RESP</MsgType>
<ReturnCode>1007</ReturnCode>
<ErrorMessage/>
</header>
<body/>
</message>
But in the wso2, the response changed to:
<text xmlns="http://ws.apache.org/commons/ns/payload"><?xml version="1.0" encoding="UTF-8"?><message><header><TransactionID>1</TransactionID><Timestamp>2012-06-04 10:45:35</Timestamp><OpCode>AAA_Response</OpCode><MsgType>RESP</MsgType><ReturnCode>1007</ReturnCode><ErrorMessage></ErrorMessage></header><body/></message>
</text>
I think I need edited builder and formatter in axis2.xml. But how to do this? Anyone can help me? Best regards.
The problem is that you haven't set up the appropriate builder and formatter in axis2.xml.
Set org.apache.axis2.format.PlainTextBuilder for content type text/plain
You can try change the server-side first, if possible.
Related
I am very new at Kotlin. I am wondering if this is possible to do it in Kotlin.
I have a request that is basically a POST to an endpoint, it sends information as part of the body, something like the following:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE...">
<some more tags...>
<request>
<clientAuth>
<client>
{client-id}
</client>
</cientAuth>
....
So I basically received some parameters (Like client-id) and I need to form this xml (as far as I am doing it at postman) and send the request.
Checking some libraries I noticed with retrofit is sort of possible, but I have no idea, is it really possible?
I know for "form url enconder" requests is simpler by using #FormUrlEncoded but not sure if there is one for xmls...
So far I got this:
an interface...
#POST("user-endpoint")
fun clientRequest(
#Field("clientId") clientId: String
): Deferred<Response<Void>>
and I invoke clientRequest from other function.
Testing the logic works fine for endpoints without parameters, but I have no idea how to send that xml, is it even possible?
I find out I can use tickaroo to represent my body as an object and then use retrofit without problem.
I'm trying to send an email, with HTML content that includes an image tag,
for example:
<img ng-src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEU...gAAASwAAAAmCC" />
unfortunately none of the mail client i'm using support this kind of "src" on image tag.
tried to Google it, it seems as known issue, but none of the answers was good for me.
by the way, i'm using AngularJS to bind the model to the html content, then pass it as an html string
to the WebApi controller, and then send it with an Smtp client.
Hope someone can help me solved this somehow,
Thanks,
Nadav S.
Yes, that is correct. Most clients do not support the "data:" url and even if they do, the size of the binary you can embed is very limited. Barely enough for a thumbnail, not enough for a real picture.
The correct way to do this is with mime multipart/related and the "cid:" url. Then one part contains the HTML and the other part contains the base64 encoded picture. The image part contains a header with a field called "Content-ID". The value is any unique string surrounded by <>. For example:
Content-ID: <xxxyyy>
In your HTML you use the following code:
<img src="cid:xxxyyy"/>
See rfc-2392 for the full specification.
In my application we use the struts URL tag in our freemarker templates like this:
<s.url action="struts-action-name"/>
The issue is that instead of appending the action url to the root url of the application it actually appends it to the current URL.
Say we hit www.example.com/community/examples/xss187ba"><ScRiPt>alert(1)</ScRiPt>506d1768713/career_development, and in the ftl for that page we have a form like this:
<form action="<s.url action="struts-action-name"/>">
The rendered ftl would look like this:
<form action="/community/examples/xss187ba"><ScRiPt>alert(1)</ScRiPt>506d1768713/career_development">
Which causes an alert to popup... has anyone dealt with this issue? Is this a bug in Struts or are we doing something wrong here?
The obvious fix is to use the URL tag like this:
<form action="<s.url value="/struts-action-name.jspa"/>">
On the other hand a quick search shows 2500 uses of that tag in the project and refactoring all those would not be a very fun/efficient job :(
Any help, comments or suggestions would be highly appreciated.
-Andre
The url tag doesn't "append" to anything--it creates a URL relative to the application, in this case based on a configured action name. Assuming an action named "f1" and a root deployment the only thing the tag would produce is an absolute URL /f1.action (or `/f1' with no extension).
Given:
<struts>
<constant name="struts.devMode" value="true"/>
<constant name="struts.action.extension" value=",,action"/>
<package name="default" namespace="/" extends="struts-default">
<action name="f1" class="radios.RadioAction" method="input">
<result name="input" type="freemarker">/WEB-INF/radios/input.ftl</result>
</action>
...
The FreeMarker fragment:
<#s.url action="f1"/>
will output:
/f1
You may need to provide more info: are you using specific plugins (like Convention), etc?
You could extend org.apache.struts2.views.jsp.URLTag and replace the exiting or add a new tag in struts-tags.tld.
I do find it weird that it does not automatically url-encode those parts of the URL, as that's what I would expect it to do.
So I would consider this a bug. Maybe contact the Struts developers about this one. Most of their other tags do automatic encoding, so it's weird that this one doesn't.
This is my Response String from HTTP Post Method
1) <?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">Open</string>
2) <?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">Close</string>
But I want only the Selected Or Result String from above lines
like from 1 response) I only want Open
from 2 response) I only want Close
How I can get this.
please reply
you can use kXML2 xml parsing api
If your handset supports JSR 172 you can follow this example to parse the data out. Otherwise you will need to write your own rudimentary string splitting/tokenizing. If you can guarantee the data is always in the format you've given, it won't be very hard.
I have the follwing code inside a facelet page:
<h:inputNumber value="bean.property">
<f:convertNumber type="currency" />
</h:inputNumber
The converter is because there can be a kind of default value inside the input field, which comes from the bean property. Everything is rendered correctly. The value inside the input field is rendered with an "€" character (e.g. "1.453 €".
When I submit the form there comes an error up:
"nameOfInputField" konnte nicht als ein Geldbetrag erkannt werden '304,00 â¬'
In english it is some like:
"nameOfInputField" could not be regognized as an amount of money '304,00 â¬'
Please have a look at the "€" character. It seems to be printed as "â¬". While it was rendered correctly before submitting the form, now it looks like "â¬" inside the error message and inside the input field.
All pages are encoded in UTF-8.
What is the reason for this error?
How can fix it?
Thanks in advance
â¬
This is typical for the € from an original UTF-8 source which is incorrectly been decoded using ISO-8859-1. Here's a small snippet which demonstrates that:
System.out.println(new String("€".getBytes("UTF-8"), "ISO-8859-1"));
All pages are encoded in UTF-8.
You're likely talking about response encoding. You need to set the request encoding as well.
To set the encoding for GET requests (basically: URI encoding), you need to consult the appserver specific documentation. As it's unclear which one you're using, here's a Tomcat targeted example: <Connector URIEncoding="UTF-8" />. To set the encoding for POST requests, you need to create a simple filter which does request.setCharacterEncoding("UTF-8") if it is null. More background information and hints can be found in this article.
Put this ontop of your facelets page:
<?xml version="1.0" encoding="UTF-8" ?>
It will instruct the facelets parser.