I created a class that extends SoapClient and overrides the __doRequest() function in order to be able to add an attachement to an external webserver that uses MTOM.
Basically, before calling the parent::__doRequest(), I edit the first parameter $request in order to add the MTOM part. My problem is that I get the "Error reading XMLStreamReader".
I'm not sure if it's because my generated message has mistakes or if the SoapClient::__doRequest() detects non-xml part and throws the soapfault.
Here is my generated soap message :
Content-Type: multipart/related; boundary=MIMEBoundary4A7AE22984E7738034;
type="application/xop+xml"; start="<0.09BC7F4BE2E4L7EF1B#example.org>";
start-info="text/xml; charset=utf-8"
--MIMEBoundary2013-04-24_0
content-type: application/xop+xml; charset=utf-8; type="application/soap+xml;"
content-transfer-encoding: binary
content-id: <0.09BC7F4BE2E4L7EF1B#example.org>
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1{endpoint} xmlns:ns2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><SOAP-ENV:Header>
<wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>{username}</wsse:Username>
<wsse:Password>{password}</wsse:Password>
</wsse:UsernameToken>
</wsse:Security></SOAP-ENV:Header><SOAP-ENV:Body><ns1:creerDepot/><param1>depot2013-04-24_0</param1><param2></param2></SOAP-ENV:Body></SOAP-ENV:Envelope>
--MIMEBoundary2013-04-24_0
content-type: application/octet-stream
content-transfer-encoding: binary
content-id: <2013-04-24_0>
--MIMEBoundary2013-04-24_0--{file}
Can someone tell me if my problem come from my generated message that contains errors or if it comes from the __doRequest() that doesn't want to send it?
Related
I have a set of requests and responses saved in files as raw petitions.
The files are like this:
--MIME_Boundary
Content-ID: <root.message#cxf.apache.org>
Content-Type: application/xop+xml; type="text/xml"; charset=utf-8
Content-Transfer-Encoding: 8bit
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header/><soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><ns2:LoadFileResponse xmlns:ns2="http://ws.loadfile.com/loadfile/ws/LoadFileService" xmlns:ns3="http://ws.loadfile.com/loadfile/ws/CheckFileService"><ns2:responseFile><ns2:status>wait</ns2:status><ns2:fileId>2356</ns2:fileId></ns2:responseFile></ns2:LoadFileResponse></soap:Body></soapenv:Envelope>
--MIME_Boundary--
I want to show in a blade template with syntax highlight and code formatted. I used highlight.js to show the colors in the code, but I don´t know how to reformat the code.
I need something like codebeautify.org (https://codebeautify.org/xmlviewer/cbf69d49) but inside my own code.
I tried using DomDocument, but it´s not strictly XML and throws exceptions when using loadXML.
Is there any class or package to help me?
Thank you!
I am trying to create a .ics file to send meeting request using php. Everything is well so far but now I must add an image to the invitation as a header for the body of the message.
How can I add a header image?
I tried to create a meeting using outlook, attach an image to it and then save as .ics file but I get a warning that the attached file may not be view able by all mail clients.
I tried ti add this code but this did not work
Note I am trying to create the .ics file using php.
Thanks
Outlook is trying to add an image in the event. This is indeed not supported by standard iCalendar format.
But from what I understand you want to add an image in the email invitation that will go to each attendee. In that case, you simply replace the text/html bodypart in your invitation with a multipart/related containing a text/html bodypart and an image/xxx bodypart, and link the two with a content-id. See https://www.rfc-editor.org/rfc/rfc2392
To get a concrete example, send an invitation from a Yahoo Calendar as they do send images along with invitation.
Here is the type of MIME structure that they send:
Content-Type: multipart/mixed;
Content-Type: multipart/alternative;
Content-Type: text/plain;
Content-Type: multipart/related;
Content-Type: text/html;
... your html version, which will include the image as <img src="cid:someuniqueid"/>
Content-Type: image/gif;
Content-ID: <someuniqueid>
... your image
Content-Type: text/calendar; charset=utf-8; method=REQUEST
Content-Type: application/ics; name="invite.ics"
I have set HTTP header in PHP as:
header("Content-Type: application/xml");
And I got following response:
<?xml version="1.0" encoding="utf-8"?>
<feedback>
<result>False</result>
</feedback>
But when I check headers, it says the response type is application/atom+xml . I need this in application/xml format. What could be the reason for this issue?
There's no reason why that shouldn't work. I've just tried a simple test case with that xml and it certainly works for me.
<?php
header("Content-Type: application/xml");
?><?xml version="1.0" encoding="utf-8"?>
<feedback>
<result>False</result>
</feedback>
Either there is more to your php that you're not showing us, or possibly there is something misconfigured in your server software.
Update
Based on the information you provided in your answer, I'd say you could fix this by changing your root element to anything that doesn't start with <feed. As I said in my comment, something is incorrectly interpreting this as being an Atom feed and rewriting the content-type.
That said, there are assumedly other strings (e.g. <rss) that might trigger other rewrites of the content-type, so it would be preferable if you could track down whatever system was responsible for the error and get rid of it.
I can't say what the technical explanation. But changing the XML content fixed my issue. It was a slight change. I just added a top level branch element,
<?xml version="1.0" encoding="utf-8"?>
<data>
<feedback>
<result>True</result>
</feedback>
</data>
I have written a script to check my Gmail account and extract XLS file attachments from the message. I am using the following code to grab the attachment from the body:
$mege = imap_fetchbody($connection,$message_number,2);
The message is being retrieved just fine. Here is a sample of the output for the above code:
-Apple-Mail=_9EBAFC63-4E12-4E64-A4F9-F8D5834F3523 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii --Apple-Mail=_9EBAFC63-4E12-4E64-A4F9-F8D5834F3523 Content-Disposition: attachment; filename=test.xls Content-Type: application/octet-stream; x-mac-type=584C5338; x-mac-creator=5843454C; x-unix-mode=0644; name="test.xls" Content-Transfer-Encoding: base64 0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAA EAAAIQAAAAEAAAD+////AAAAAAAAAAD///////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ///////////////bABpAGIAcgBpADEAHgDwAAAACACQAQAAAAIA2gcBQwBhAGwAaQBiAHIAaQAxAB4A8AAAAAgAkAEA...
This is expected since the XLS file is base64 encoded. However, when i decode the message and save to a file, I am getting an empty excel file. But, it is an excel file.
I am using this to decode the content before writing to a file:
$message=imap_base64($mege);
I am wondering if there is anything more I am supposed to be doing to the attachment in order to populate the file.
You are fetching the full body of a mail message, not just the attachment. What is missing is the code to parse the MIME structure, locate the actual interesting part, extract that part from the MIME container and only after that decode according to the Content-Transfer-Encoding header (your "base64" in this particular case). You just cannot blindly base64-decode the whole body and hope to get an attachment in return.
i want to create a empty spreadsheet with google docs api but i get the error: could not convert document.
$xml = "--END_OF_PART\r\n".
"Content-Type: application/atom+xml;\r\n\r\n".
"<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:docs=\"http://schemas.google.com/docs/2007\">
<category scheme=\"http://schemas.google.com/g/2005#kind\"
term=\"http://schemas.google.com/docs/2007#spreadsheet\"/>
<title>".$name."</title>
</entry>\r\n".
"--END_OF_PART\r\n".
"Content-Type: text/csv;\r\n\r\n".
"--END_OF_PART--\r\n";
This xml is sent to the server of google with a post with param convert=true
Then i got the error: could not convert document.
When i use the mime-type 'application/vnd.oasis.opendocument.spreadsheet' instead of 'text/csv' and do not add the param convert=true i get an internal error.
Docs List API v3 is deprecated. Use Google Drive API instead. You can create a file with the insert call:
https://developers.google.com/drive/v2/reference/files/insert
the mimeType for a native spreadsheet would be:
application/vnd.google-apps.spreadsheet