I want to ask you about sending files using WCF.
I want to implement service, to send fax and emails. My case looks like that:
The service will be hosted in windows service.
I would like to make this service visible on the local network only. (So I will probably use netTcpBinding)
and It will be great, when a customer who wants to send a fax or send email with attachments, will have to use only the "SendFax" function with specific parameters. I mean.. How to do that, so it would be very simple for client?
I think the biggest attachment could be up to 20MB, I don't know how it looks like in case of a fax. But I think it will be MS Word file, so 20MB will upper limit.
I want to ask you how to implement, the server-side part of WCF service?
Use buffered upload or streamed upload ?
Could you give me a link to good example or article ?
Any help will be great,
Thanks
A WCF service endpoint can accept a byte array of variable sizes so it shouldn't be a problem for a client to send a pdf,word, etc document as a byte[] to the service. The default netTcpBinding settings will need to be adjusted to accomodate the large file sizes.
Your windows service will host your WCF endpoint (e.g., SendDocument()).
The service's implementation of this method will use the standard System.Net.Mail.SmtpClient class to send the email. See the MSDN documentation for SmtpClient and especially the MailMessage class, which among other things has an Attachments property you can use.
Related
I work with a dozen pieces of equipment whose operating software has the option to send e-mails on error. I would prefer to capture the details of that e-mail on the host PCs that run them (i.e. for logging, communicating details automatically via Slack, etc.) rather than them going to an inbox somewhere.
Is there a way to have the software e-mail an address that is essentially a lightweight piece of code running on the same PC mimicking something like an SMTP server (that will allow me to get after the message's contents)? Other solutions I have seen are along the lines of setting up a full-blown server which seems like overkill.
You may configure SmtpClient to save email to a specific folder instead of sending it over the wire. Check this answer.
Also you must design your system in the way it could work with different implementations of your 'sender', so that you can replace it when you need that, for example during testing. In this case you can easily provide proxy implementation that will capture email content and then send it to localhost, or add aspects (make retries, logs performance...).
Its really frustating that EmailComposeTask doesn't have any way to send attachments. I googled this and found MailMessage dll. I don't know whether it is secure or not because user gonna send his password.
Now I am thinking tot build my own service, send data from phone to service, and service will use smtp to send email with attachment.
Now I want to ask, Am I right? What kind of service I use?
I dont know about security concerns of MailMesssage.dll.
However, if you wish to send transactional EMails, then there are few services available. In such a case, you will not be required to create your own service. The popular one's are:
Sendgrid
Mandrill by MailChimp
MailGun by Rackspace
All services provide free tier and may be helpful, if you need to send, less EMails. Moreover, besides SMTP, these services provide Web APIs, so you can send mails using REST interface.
I have implemented a desktop application.I need to send mail.My application can send mail directly.Now i need to implement this tasks when PC is connected through a proxy server.If any one has done it before please help me..
Mail uses smpt. I assume your goal is connecting through an isp/company provided proxy. Those usually only handles http/https. You will not be able to use such a proxy for sending mails since they use different protocols.
Maybe your isp/company have an upstream smtp you can use?
I am working on a web service interface, where my WCF application works both as a Client and a Service. There are multiple Java clients that need to connect to my web service. I will need to accept stream of images and documents and send back stream of converted images.
I would also need to connect to other Java services to send the image streams as a payload to be stored in a database. I am new to web services, is there good documentation on how to enable streaming contracts between WCF and Java clients and vice verse.
If I want to return other information along with the stream of (group) images to the client, how would I do that? Like the size of each image, the offset in the stream, so they can separate images.
Thanks
In order to return additional information with your images you will need to define a DataContract which contains the metadata elements as well as a collection to contain your images. Perhaps representing your image collection as a byte array rather than just returning a raw stream of images? There are several ways to address the issue, however the best solution depends on your design requirements.
I'm writing UI to test an asmx web service. Server and client are .NET. Client proxy has been generated using wsdl.exe.
I would like to intercept and store a string representation of outgoing and incoming SOAP messages generated as a result of calling methods on the web proxy, so I can add a feature to the UI which will show the message just sent/received.
I dimly recall there are two pairs of extension points where code can can be added to intecept the message but I cannot remember how this was done. I think the examples I have in mind involved compressing some part of the message on the client and the reverse on the server, even though in my scenario, I want to store rather than alter the message.
Any hints and help gratefully received.
(I've partially implemented a SoapExtension. I don't understand how the ChainStream method works, and I'm not sure how to notify a listener that a soap message has been trapped (since I'm not in control of instantiating the soap extension).'
You're on the right track with SoapExtension. Did you see the documentation and example here? http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapextension.aspx
The idea with ChainStream is you get passed the network stream that the request would be written to, and you have the option of returning a different stream. So if you want to save a copy of the request, return a MemoryStream, which the web services client will write the request into, and then in the ProcessMessage call you can copy the data out of there and pass it to your UI.
Another way to capture the XML is sent through the Wireshark application. It intercepts the communication network card.
In my case, I called a service that had as part of his address to string PIOSOS. I used the Find Packet window and searched.
Then located the XML.
See the picture.
(I know ... it's not a programmatic way, but it has its value. Lol)
I would suggest 2 tricks :
subclassing the proxy and overloading your methods (a little bit boring but you can generate code like in this project : http://ftwsf.codeplex.com/)
using Async signatures and subcribe to 'Completed' events of each methods (you can do this by reflection to avoid writting to much code)
If you need more info about these tricks, just let me know.
You'd really be better off using WCF as your client technology. You could then simply use WCF message-level tracing to log the incoming and outgoing messages. This is done simply through configuration.
There's no reason you have to use an ASMX client just because you are using an ASMX service.