Copy link to clipboard
Copied
Hi,
I'm trying to get a zip file from a NET web service but I get this error:
Cannot perform web service invocation GetPolicy. | |
The fault returned when invoking the web service operation is:org.apache.axis2.AxisFault: Must Understand check failed for header http://tempuri.org/ : FileName at org.apache.axis2.engine.AxisEngine.checkMustUnderstand(AxisEngine.java:105) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:171) at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:364) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) at org.tempuri.EmissionServiceStub.getPolicy(EmissionServiceStub.java:222) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at coldfusion.xml.rpc.Axis2S... ' |
This is my code.
<cfinvoke webservice = "http://URL.com.mx/IntegrationService/EmissionService.svc?wsdl"
method = "GetPolicy"
returnvariable="aString" >
<cfinvokeargument name="clave" value="ABCR2O14"/>
<cfinvokeargument name="producto" value="ABCGUA"/>
<cfinvokeargument name="llave" value="ABC53D35OUHGX2O14"/>
<cfinvokeargument name="fileExtension" value="zip"/>
<cfinvokeargument name="policy" value="001_PRO-RCSED_00000002_01_0"/>
<cfinvokeargument name="fileName" value="caratula"/>
</cfinvoke>
The result must have a binary file I must use the content type "Application/Octet-Stream" and a header "Content-Disposition".
I don't know if I have to use CFHTTP for get the file.
Any recomendation?
Yesssss ....I have the solution.
<cfheader name="Content-Disposition" value="attachment; filename=my_saved_file.zip">
<cfcontent type="application/octet-stream" variable="#ToBinary(results[1].xmltext)#">
Finally I have the ZIP file!
For to make the XML SOAP Request I used the SOAPUI Aplication. It make me the XML and send as a parameter.
Thanks BKBK
Copy link to clipboard
Copied
Going by the error message, we may send fileName as a header , and include the header mustUnderstand (having just found out cfhttpparam wont accept mustUnderstand as attribute). Something like this:
<cfhttp url="http://URL.com.mx/IntegrationService/EmissionService.svc?wsdl" method="post" path="C:\temp" file="my_saved_file.zip">
<cfhttpparam type="header" name="fileName" value="caratula">
<cfhttpparam type="header" name="mustUnderstand" value="true">
<cfhttpparam name="clave" value="ABCR2O14">
<cfhttpparam name="producto" value="ABCGUA">
<cfhttpparam name="llave" value="ABC53D35OUHGX2O14">
<cfhttpparam name="fileExtension" value="zip">
<cfhttpparam name="policy" value="001_PRO-RCSED_00000002_01_0">
</cfhttp>
<cfheader name="Content-Disposition" value="attachment; filename=my_saved_file.zip">
<cfcontent type="application/octet-stream" file = "C:\temp\my_saved_file.zip" deleteFile = "no">
Message was edited by: BKBK
Copy link to clipboard
Copied
Thanks BKBK.
And how can I tell to the cfhttp that I want to use the GetPolicy method from the webservice?
Is it correct that in the parameters that I need to send put type="formField" because is required in the cfhttpparman and you missed.
Like this:
<cfhttpparam type="formField" name="clave" value="ABCGU4R2O14">
I already run but the zip file is empty.
Copy link to clipboard
Copied
Yes, add type="formfield". I also think you may add the method as the parameter
<cfhttpparam type="formField" name="method" value="GetPolicy">
Copy link to clipboard
Copied
I still receive an empty zip file.
I looking for and trying from a SOAP request.
Thanks.
Copy link to clipboard
Copied
I dumped the cfhhtp and this is
struct | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Charset | [empty string] | ||||||||||||||||||||||
ErrorDetail | [empty string] | ||||||||||||||||||||||
Filecontent | A CFHttp.Filecontent variable is not created if a file path is specified. | ||||||||||||||||||||||
Header | HTTP/1.1 415 Cannot process the message because the content type 'application/x-www-form-urlencoded' was not the expected type 'text/xml; charset=utf-8'. Connection: close Date: Sun, 13 Apr 2014 16:24:28 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Cache-Control: private Content-Length: 0 | ||||||||||||||||||||||
Mimetype | Unable to determine MIME type of file. | ||||||||||||||||||||||
Responseheader |
| ||||||||||||||||||||||
Statuscode | 415 Cannot process the message because the content type 'application/x-www-form-urlencoded' was not the expected type 'text/xml; charset=utf-8'. | ||||||||||||||||||||||
Text | YES |
Copy link to clipboard
Copied
Statuscode 415 Cannot process the message because the content type 'application/x-www-form-urlencoded' was not the expected type 'text/xml; charset=utf-8'.
That suggests to me that the service expects you to make a SOAP call. You could do something like this, substituting somevar1, someVar2 and someDomain for the relevant values:
<!--- SOAP message to send to Web Service--->
<cfsavecontent variable="msg"><?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<tns:someVar1 soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.someDomain.com/services/soap/">
<fileName xsi:type="xsd:string">caratula</fileName>
<clave xsi:type="xsd:string">ABCR2O14</clave>
<producto xsi:type="xsd:string">ABCGUA</producto>
<llave xsi:type="xsd:string">ABC53D35OUHGX2O14</llave>
<fileExtension xsi:type="xsd:string">zip</fileExtension>
<policy xsi:type="xsd:string">001_PRO-RCSED_00000002_01_0</policy>
</tns:someVar1>
</soapenv:Body>
</soapenv:Envelope>
</cfsavecontent>
<!--- Invoke web service and send message--->
<cfhttp url="http://URL.com.mx/IntegrationService/EmissionService.svc?wsdl" method="post" path="C:\temp" file="my_saved_file.zip">
<cfhttpparam type="header" name="content-type" value="text/xml">
<cfhttpparam type="header" name="mustUnderstand" value="true">
<cfhttpparam type="header" name="SOAPAction" value="">
<cfhttpparam type="header" name="content-length" value="#len(msg)#">
<cfhttpparam type="header" name="charset" value="utf-8">
<cfhttpparam type="xml" name="someVar2" value="#trim(msg)#">
</cfhttp>
<!--- Web Service response --->
<cfheader name="Content-Disposition" value="attachment; filename=my_saved_file.zip">
<cfcontent type="application/octet-stream" file = "C:\temp\my_saved_file.zip" deleteFile = "no">
Copy link to clipboard
Copied
Thanks.
I already did the SOAP Request and it was Ok.
And this was the response
Statuscode | 200 OK |
Filecontent | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:FileName s:mustUnderstand="1" xmlns:h="http://tempuri.org/">001_PRO-RCSED_00000002_01_0-CaratulaDA.zip</h:FileName><h:Length s:mustUnderstand="1" xmlns:h="http://tempuri.org/">112484</h:Length><h:errors s:mustUnderstand="1" i:nil="true" xmlns:h="http://tempuri.org/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/></s:Header><s:Body><RemoteFileInfo xmlns="http://tempuri.org/"><FileByteStream>UEsDBBQAAAAIAByLUNhcmF0dWxhREEucGRmCgAgAAAAAAABABgAbu9TA5AO9Ryux9+LErXhDt8BxP81lr5/4yNXHjA38qnTbZ0aJXizRXs0ErmRXXFYVNwblS1j7CxzbOIjgG</FileByteStream></RemoteFileInfo></s:Body></s:Envelope> |
And so know, I need to transform the FileByteStream to a file.
Copy link to clipboard
Copied
I already parse the XML response and get the fileByteStream
<cfset soapResponse = xmlParse(trim(httpResponse.fileContent)) />
<cfset results = xmlSearch(soapResponse,"//*[local-name()='FileByteStream']") />
<cfset filebyteS = results[1].xmltext />
Do you know how can I tranform the fileByteStream to a file?
Copy link to clipboard
Copied
Yesssss ....I have the solution.
<cfheader name="Content-Disposition" value="attachment; filename=my_saved_file.zip">
<cfcontent type="application/octet-stream" variable="#ToBinary(results[1].xmltext)#">
Finally I have the ZIP file!
For to make the XML SOAP Request I used the SOAPUI Aplication. It make me the XML and send as a parameter.
Thanks BKBK