Open ilariagiannetti opened 9 years ago
Hello, I won't be troubling myself with generating request and adding files "manully" :confused: BeSimple's and PHP's SoapClient pretty much handles it all. Leaving it for BeSimple to handle (+ classmap) would be much simpler and clearer.
But I can point you to files you should investigate, if you want to do it "manually".
BeSimple/SoapCommon/Converter/MtomTypeConverter.php
, convertPhpToXml
method.
You can see how file content element is changed. It generates an XOP:Include
element with reference (href
) to binary attachment.
Also notice MimePart
(BeSimple\SoapCommon\Mime\Part
) constructor and that attachment is added.
BeSimple/SoapClient/MimeFilter.php
, filterRequest
method.
Filter which adds attachments to request.
If you are registering more filters, then this filter must be registered last.
``
Also you can use BeSimple\SoapClient\WsSecurityFilter
to add WS-Security headers.
Which would look like that
use BeSimple\SoapClient\WsSecurityFilter;
$wssFilter = new WsSecurityFilter($addTimestamp = true, $expires = 300, $actor = null);
$wssFilter->addUserData(
'username',
'password',
WsSecurityFilter::PASSWORD_TYPE_DIGEST // or WsSecurityFilter::PASSWORD_TYPE_TEXT
);
$soapClient->getSoapKernel()->registerFilter($wssFilter);
Thanks for the answer and for the detailed information. A further question: if we want to attach the file directly via besimple (not manually), which call should we do? In particular, at what point in the code and how we can indicate the attachment file the client must send? Could you give us an example ? Thank you very much for helping
BeSimple provides a test for MTOM.
BeSimple/SoapClient/Tests/ServerInterop/MTOMClient.php
BeSimple/SoapClient/Tests/ServerInterop/MTOMServer.php
you might need to update path to composer autoload.php
and MTOM.wsdl
.
You can start server with shell script BeSimple/SoapClient/Tests/bin/phpwebserver.sh
.
If you will still have problems, email me your wsdl. I might prepare sample for it.
Sorry @minimihi i have same problem.
I can not generate a MTOM. :(
could you tell me what are the basic steps to create a multipart message to send with curl ?
Help me. Please
Thanks
i need to send a file using MTOM and BeSimple soap with php. Does anyone has an example to show me?
As minimihi already mentioned have a look at the tests for examples how to use MTOM: https://github.com/BeSimple/BeSimpleSoap/tree/master/src/BeSimple/SoapClient/Tests/ServerInterop
Hello, I'm also trying to use MTOM to send a file (pdf) to a specific server method. I didn't find in the example from minimihi and aschamberger how we can create the body message. I try to understand BeSimple/SoapCommon/Converter/MtomTypeConverter.php but without any documentation it's quite hard to find the solution. did Anybody do that (attached a file content with XOP)? Many thanks if someone can help
Hi,
i sent some files using BeSimple/MTOM and used the BeSimple/SoapClient/Tests/ServerInterop/MTOMClient.php as example. I did not have to understand the way the library works. I put the document content in my classe and call the service using the besimple soap client. BeSimple make the work of mount the mtom request, putting de xop link in the middle of the message and attaching the binary content at the end of the message.
Marcos.
Thanks Marcos for your help. I don't try anymore to study the mechanism and work with the example. But I have difficulties to set the Content-Type. (It is Content-Type: application/octet-stream; charset=utf-8 and I would like application/pdf) Any idea of what could be wrong? Thank you if you can help me. Christophe
Good morning, thanks for the BeSimple bundle, it works great! Since I'm new to using MTOM mechanism and since it's not easy to find php code that supports MTOM attachments in SOAP messages, I would need an example. In particular, i have to implement a SOAP client that sends a message with attachment (using MTOM mechanism) to a WS service listening. My client without attachments works. My problem that i can not manage attachment part, I do not know what methods to call and how. I set the header but I can not dial the message header and attachment. It would be possible to have an example of a client sending a request with MTOM attachment ? I attach my code. Thank you in advance.
--- MY CODE --- $nome = "richiesta_".time().".zip"; $clientbuilder = $this->get('besimple.soap.client.builder.client_name'); $soapClient= $clientbuilder->build();