issue with elang (yaws_soap_lib based) soap client - soap

I have python's based soap server and tried to call it functions using erlang (yaws_soap_lib based) soap client:
1> inets:start().
ok
2> yaws_soap_lib:call("http://127.0.0.1:90/soap/system/wsdl","cpu_count",[]).
{ok,undefined,undefined}
here is what I was able to see with tcpdump program (answer of server to client):
HTTP/1.1.200.OK..Date:.Wed,.20.Oct.2010.15:56:11.GMT..Server:.Apache/2.2.15.(Unix).mod_wsgi/2.5.Python/2.5.2..Content-Length:.276..Content-Type:.text/xml
< SOAP-ENV:Envelope.xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance".xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" > < SOAP-NV:Body> < cpu_countResponse>< cpu_countResult.xsi:type="xs:int">2< /cpu_countResult>< /cpu_countResponse>< /SOAP-ENV:Body>< /SOAP-ENV:Envelope>
as one can see in envelope server answer 2, but yaws_soap_lib:call was not able to see that 2 in the answer. is there an option to fix the issue?
Thanks.

I suspect you have not specified NS prefix, which is by default "P" or "p" (I can't remember). So whenever you receive response soap client is not able to deserialize it, because it is represented in erlsom model as a record 'P:cpu_countResponse'.

Related

Copy a file from client to server via rest end point using golang

I want to copy a file from the client to the server through the rest end point exposed by the server. I referred the various questions and answers in stackoverflow but I could not get a clear picture of it.
I just want a sample client and server code in golang to copy the file from client and save it on the server.
Thanks in advance.
Direction: Server to Client
So -- both sides are in Go? Okay, let's start with the server side. See my WebLoad.go file from my CSVStorageServer server: (Link to Github)
At line 17, I define the handler for the web server. This method will build a zip file on-demand and send it to the browser. The important part regarding to your question are line 77 up to 82. Here, I set the headers for the client, e.g. content length and type. Line 82 sends the whole data to the client side. It copies the bytes from the on-demand zip file to the wire.
On the client side, you trigger e.g. a GET request and store the result. Here an example: https://golang.org/pkg/net/http/#example_Get
With http.Get(... you trigger the GET request. With ioutil.ReadAll(res.Body) you read all bytes from the server and store it to a variable. Afterwards, you could write the bytes to the disk or process it in-memory.
I hope, this answer helps you.
Best regards, Thorsten
Edit #1:
Regarding the REST end-point, cf. the server definition (link to Github). Line 16 defines the REST end-point for this handler. In this case, it gets available as /load. You could use any REST-like path here, e.g. /open/file/USERID/send, etc.
Direction: Client to Server
In order to copy a file from client to server side, similar operations are necessary. On the client side, a POST request is necessary as multipart/form-data. Here is a good example for this: Link to a blog post. This example considers also the server part. The relevant client part is the function func postFile(filename string, targetUrl string) error { ... }.
For the server part, here an own example: Link to Github. This example receives an file from the client and writes it to a MongoDB database. The relevant parts are:
Line 39 read the file from the client: file, fileHeader, fileError := request.FormFile("file") The result is a handle to this uploaded file.
Line 60 copies all bytes from the source (browser or Go client) into a destination (here, the MongoDB): _, errCopy := io.Copy(newFile, file).
Edit #2:
Here is a full working example: https://github.com/SommerEngineering/Example010 where client and server are in the same program. It should be easy to split it into two programs.

JMeter TCP Sampler doesn't recognize end of stream

I'm trying to run a simple test with TCP Sampler
When using default TCPClient class, after the response timeout time passes, I receive a correct response from the server, and then Error 500 in sampler results:
Response code: 500 Response message:
org.apache.jmeter.protocol.tcp.sampler.ReadException:
It seems like that JMeter does not recognize end of message characters (the server sends \r\n).
How can I configure JMeter to see the EOM?
I tried to use BinaryTCPClientImpl, and set tcp.BinaryTCPClient.eomByte = 13 in Jmeter.properties, but binaryTCPClient expects HEX data, while I send human readable string, and it still ignores the eomByte...
Any ideas?
Found the problem.
Those server did not sent \r\n in several cases.
Everything started working after the server was fixed.
I came accross the same behaviour and examined the offered responses (sending \r\n at the end of the message in the server side \ setting the eol byte value option in the gui) but it didn't work for me.
My solution: Following this question I found that \0 is the eol character Jmeter expects in TCP sampler. when my server terminates the messages with \0 - the message is receieved in Jmeter.
Some more references: Jmeter documentation (TCPClientImpl chapter - that's where the tcp.eolByte is discussed).
Some option: if the size of the messages is constant, one can examine LengthPrefixedBinaryTCPClientImpl (see this discussion).
Anyone give me a solution for this error. Why I m getting 500 response code why jmeter throwing the read exception and what is the solution for this error if I already received my success response.
TCP Sampler will not return until EOF is received.
Set your own EOF byte value at TCP Sampler.
The server sends a stream at the end of EOF byte value.

Applescript and SOAP: Transport Error

I'm new to Applescript, but I followed this handy tutorial, the first Google result for "Applescript webservice": http://developer.apple.com/internet/applescript/applescripttoperl.html
So I have (hopefully) a perl script giving me a webservice at http://localhost:8001
but when I run
set p to {"http://www.perl.com/pace/perlnews.rdf", "http://www.perl.com/pace/perlnews.rdf"}
using terms from application "http://www.apple.com/placebo"
tell application "http://localhost:8001" to return call soap {method name:"fetch_headlines", method namespace uri:"http://localhost:8001", SOAPAction:("http://localhost:8001" & "#" & "fetch_headlines"), parameters:p}
end using terms from
I get
"got an error: Transport error"
Google is failing me. Any ideas where to look?
Transport error mean that the communication endpoint does not respond. Do you forget start the perl soap-server script (for listening at port 8001)?
And after you start your perl SOAP server, your applescript SOAP-client code should be
set p to "http://search.cpan.org/uploads.rdf"
using terms from application "http://www.apple.com/placebo"
tell application "http://localhost:8001/Server" to return call soap {method name:"fetch_headlines", method namespace uri:"http://localhost:8001/Server", SOAPAction:("http://localhost:8001/Server" & "#" & "fetch_headlines"), parameters:{uri:p}}
end using terms from
ps: http://www.perl.com/pace/perlnews.rdf does not exists...

CURLOPT_FOLLOWLOCATION equivalent for socket adapter in Zend_Http_client

I would like to use the socket adapter instead of Curl for my code but however this the problem i am facing.
(case 1 :) I am querying a server for response using Zend_http_client (default socket adapter) and I am getting a 404 error,
(case 2 :) while, for the same server as above, I am getting a response back when using CURL adapter with CURLOPT_FOLLOWLOCATION set to boolean true. Also, if I remove this parameter (CURLOPT_FOLLOWLOCATION) from the config array , I get the same error as in the case 1.
So, setting the CURLOPT_FOLLOWLOCATION should be doing the trick (yes, there is internal redirection happening in the target server) and hence I am looking for an equivalent parameter/option for in case of Socket Adapter.
Any help is greatly appreciated. Thanks in advance

Use DTD to describe XML returned in RESTful service?

Given the service:
> GET /hotel
< HTTP/1.1 200 OK
< <hotel>
< <a>aaa</a>
< <b>aaa</b>
> <c>aaa</c>
< </hotel>
Should one reference a DTD in the XML returned from the server?
Would this better allow a client to validate the response?
Considering the markup you have chosen appears to be custom to your requirements then I would expect to see a media-type such as
application/vnd.yourcompany.hotel+xml
in your content-type HTTP header. Based on this content-type, the client will know whether it has the knowledge to process this representation.
The media-type header can help your client know what kind of document to use. It can also help you version the service by having different document types for each version.
application/vnd.yourcompany.hotelv1+xml
application/vnd.yourcompany.hotelv2+xml
etc.
The client can also specify which kind of document it would like back in the Accepts header.
It's certainly good practice to reference your DTD/schema, and yes, it will allow clients to validate the response, if they choose to. They often won't.