Daniel Mtz
Daniel Mtz

Reputation: 21

Error consuming a web service with ColdFusion 11

I am trying to consume a web service using the URL they gave me. When running the page I am getting the following error:

Cannot perform web service invocation RegistraFacturaXML.

The fault returned when invoking the web service operation is: org.apache.axis2.AxisFault: Transport error: 302 Error: Redirect at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:310) at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:194) at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:402) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) at gt.com.megaprint.www.webservice.SSO_wsEFacturaStub.registraFacturaXML(SSO_wsEFacturaStub.java:8431) at sun.reflect.NativeMethodAccessorImpl.inv... ''

I have checked that port 443 is open and I installed the certificate that I was sent. I called the web service using SoapUI and it works for me. I do not know what to do now?

this is my code:

`<cfsavecontent variable="strdata">
 <FACTURA>
  <ENCABEZADO>
    <NOFACTURA>1026</NOFACTURA>
    <RESOLUCION>2016-50-51-35</RESOLUCION>
    <IDSERIE>TBCF</IDSERIE>
    <EMPRESA>883</EMPRESA>
    <SUCURSAL>1</SUCURSAL>
    <CAJA>001</CAJA>
    <USUARIO>JCRUZ</USUARIO>
    <MONEDA>GTQ</MONEDA>
    <TASACAMBIO>1</TASACAMBIO>
    <GENERACION>O</GENERACION>
    <FECHAEMISION>20/12/2016</FECHAEMISION>
    <NOMBRECONTRIBUYENTE>TRANSPORTES ESTRATEGICOS,S.A.</NOMBRECONTRIBUYENTE>
    <DIRECCIONCONTRIBUYENTE>20 AVENIDA 7-95 ZONA 14 GUATEMALA</DIRECCIONCONTRIBUYENTE>
    <NITCONTRIBUYENTE>5559845-5</NITCONTRIBUYENTE>
    <VALORNETO>8869.68</VALORNETO>
    <IVA>1064.36</IVA>
    <TOTAL>9934.04</TOTAL>
    <DESCUENTO>0.00</DESCUENTO>
    <EXENTO>0.00</EXENTO>
  </ENCABEZADO>
  <OPCIONAL>
    <TOTAL_LETRAS>NUEVE MIL NOVECIENTOS TREINTA Y CUATRO  QUETZALES 04/100 ***********************</TOTAL_LETRAS>
  </OPCIONAL>
  <DETALLE>
    <LINEA>
      <CANTIDAD>8</CANTIDAD>
      <DESCRIPCION>11R22.5 16PR LLD37 TRACCION</DESCRIPCION>
      <METRICA>PC</METRICA>
      <PRECIOUNITARIO>1241.76</PRECIOUNITARIO>
      <VALOR>9934.04</VALOR>
    </LINEA>
  </DETALLE>
</FACTURA>
 </cfsavecontent>
<cfinvoke webservice="https://www.ifacere.com/lineapruebas/sso_wsefactura.asmx?wsdl" method="RegistraFacturaXML" returnvariable="RegistraFacturaXMLResult" wsversion="2"> 
    <cfinvokeargument name="pXmlFactura" value="<![CDATA[#strData#]]>"/> 
</cfinvoke> 
<cfoutput>#RegistraFacturaXMLResult#</cfoutput>

`

Upvotes: 1

Views: 741

Answers (1)

ah7866
ah7866

Reputation: 136

I called the web service using SoapUI and it works for me.

I remember a similar situation that I had encountered. The reason I had issues was because the web service was expecting complex types i.e. the web service had minoccurs and maxoccurs defined.

The solution I ended up with was to use the SoapUI response that worked and save that as my Soap request. Then use the CFHTTP tag. See the post below that helped me write my own SOAP solution. Neither CF 11, nor any version that I am aware of, handles the minoccurs or maxoccurs complex types web service.

Making SOAP Web Service Requests With ColdFusion

Upvotes: 2

Related Questions