I have been a coldfusion developer since 1999 but the last few years I have been working more with other technologies. Recently I have been asked to implement a client for a webservice that allows one to order pharmacists medicines at a wholesale depot.
The full service description can be found here: http://services.bitler.be/GenericServices/OrderProcessingService.svc?singleWsdl
I think the relevant sections for consuming the client are the following ones, but feel free to look at the full description in case I missed anything:
- The function:
<wsdl:operation name="ProcessOrder">
- The expected parameters:
<xs:complexType name="OrderProcessingRequest"> <xs:complexContent mixed="false"> <xs:extension .... base="q1:RequestBase"> <xs:sequence> <xs:element minOccurs="0" name="CustomerEmail" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="ProcessOrderLines" nillable="true" type="tns:ArrayOfProcessOrderLine"/> <xs:element ... minOccurs="0" name="Site" type="q2:FebelcoSite"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:element name="OrderProcessingRequest" nillable="true" type="tns:OrderProcessingRequest"/> <xs:complexType name="ArrayOfProcessOrderLine"> <xs:sequence> <xs:element minOccurs="0" maxOccurs="unbounded" name="ProcessOrderLine" nillable="true" type="tns:ProcessOrderLine"/> </xs:sequence> </xs:complexType> <xs:element name="ArrayOfProcessOrderLine" nillable="true" type="tns:ArrayOfProcessOrderLine"/> <xs:complexType name="ProcessOrderLine"> <xs:sequence> <xs:element minOccurs="0" name="ProductNumber" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="QuantityRequested" type="xs:int"/> </xs:sequence> </xs:complexType> <xs:element name="ProcessOrderLine" nillable="true" type="tns:ProcessOrderLine"/> <xs:complexType name="RequestBase"> <xs:sequence> <xs:element minOccurs="0" name="ApbNumber" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="BSKey" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="WholesalerId" type="xs:int"/> </xs:sequence> </xs:complexType> <xs:element name="RequestBase" nillable="true" type="tns:RequestBase"/>
This is what I have come up with so far:
cffunction name="placeOrder" access="remote" returntype="any">
<cfargument name="apbnr" required="yes" type="string">
<cfargument name="bskey" required="yes" type="string">
<cfargument name="cnk" required="yes" type="string">
<cfargument name="quantity" required="yes" type="string">
<cfargument name="site" required="yes" type="string">
<cfscript>
orderProcessingRequest = StructNew();
orderProcessingRequest.apb = apbnr;
orderProcessingRequest.bskey = bskey;
orderProcessingRequest.vestiging = site;
productOrderLines = ArrayNew(1);
productOrderLine = StructNew();
productOrderLine.cnk = cnk;
productOrderLine.quantity = quantity;
productOrderLines[1] = productOrderLine;
orderProcessingRequest.productOrderLines = productOrderLines;
ws = CreateObject("webservice", "http://testservices.bitler.be/GenericServices/OrderProcessingService.svc?singleWsdl" );
newOrder = ws.ProcessOrder(orderProcessingRequest);
writeoutput(newOrder);
</cfscript>
</cffunction>
But it keeps throwing me errors at the line the function is invoked. I suspect I have an error in the "orderProcessingRequest", but I honestly can't figure out where.
Cannot perform web service invocation ProcessOrder.
The fault returned when invoking the web service operation is:
org.apache.axis2.AxisFault: There was an error while requesting your data. Please contact Bitler support with error ref (O150214084734).
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
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.OrderProcessingServiceStub.processOrder(OrderProcessingServiceStub.java:193)
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.Axis2ServiceProxy.... ''
The error occurred in C:/ColdFusion10/cfusion/wwwroot/_cfc/febelco.cfc: line 43
41 : orderProcessingRequest.productOrderLines = productOrderLines;
42 : ws = CreateObject("webservice", "http://testservices.bitler.be/GenericServices/OrderProcessingService.svc?singleWsdl" ); //, { refreshWSDL=true, wsversion=1 }
43 : newOrder = ws.ProcessOrder(orderProcessingRequest);
44 : writeoutput(newOrder);
45 : </cfscript>
Sincerely, Jurgen