I've been running into some challenges with a web service I'm trying to use of from ColdFusion. The service (AccountsService), has a method, GetAccountLinksByUser that returns accounts associated with a given user. This method accepts two arguments:
UPN, which is just a unique string to identify the user. This is no problem, as far as I can tell.
sourceType. This is ultimately a string, but is defined in the WSDL as simple type with one of three possible values. Here's a relevant sections of XML from the WSDL:
<xsd:simpleType name="SourceType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="All"/>
<xsd:enumeration value="Manual"/>
<xsd:enumeration value="System"/>
</xsd:restriction>
</xsd:simpleType>
The problem is that I can't seem to just pass the string "All", "Manual", or "System" into the web service. The stub that CF generates has the following signature for this method:
getAccountLinksByUser(java.lang.String, org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType)
This appears to suggest that I need to pass in an instance of org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType. However, I can't create an instance of that type (easily) as it doesn't appear to be in a class path that CF searches. I tried wrapping the classes that CF generates into the /stubs directory into a jar and putting them in a class path. This did work, in that I could now create an instance of org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType, but I was still unable to pass that into the getAccountLinksByUser method.
As requested, here is the code I'm using to call the web service:
<cfset accountsService = CreateObject("WebService", "http://local.hostname/libraries/com/foo/bar/staging/AccountsService.wsdl") />
<cfset SourceType = CreateObject("java", "org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType") />
<cfset accounts = accountsService.getAccountLinksByUser("username#domain", SourceType.All) />
More information. The publisher of the web service does not publish their WSDL publicly. This was emailed to me and I'm loading the WSDL from my my local development site.
The specific error I'm getting is:
Cannot perform web service invocation getAccountLinksByUser.
The fault returned when invoking the web service operation is:
Cannot perform web service invocation getAccountLinksByUser. The fault
returned when invoking the web service operation is: ''
java.lang.IllegalArgumentException: argument type mismatch
I'm not really sure where to head at this point. Any suggestions?
The service is written in .NET.
I ran a few tests and it seems related to the switch to Axis2 in CF10. I am honestly not sure exactly what about enumeration's changed between 1 and 2. However, setting the version level back to Axis1 should do the trick:
<cfscript>
args = { refreshWSDL=true, wsversion=1 };
ws = createObject("webservice", "http://mysite/test.asmx?wsdl", args);
result = ws.getAccountLinksByUser("test#somewhere.com", "All");
writeDump(result);
</cfscript>
Related
I tried creating a web service in ColdFusion, for that I just created a component with a function inside it having access="remote"
<cfcomponent displayname="testPost" hint="testing.." output="yes">
<cfsetting enablecfoutputonly="true" showdebugoutput="true">
<cffunction access="remote" output="true" name="testPostReq" displayname="testPostReq" description="testing" returntype="any">
<cfset p=9>
<cfreturn p>
</cffunction>
</cfcomponent>
Now I wanted to call this webservice and I am trying to hit this in my browser, https://sampleapp.xyz.com/DirectoryToCfc/CfcName.cfc?wsdl but in browser I am getting "Unsupported Operation. Check application log for more details." when I checked application logs I saw this log there:
"Warning","ajp-bio-8013-exec-4","09/27/21","12:57:55","COMPONENTUTILS","To use Component Browser, enable RDS Service using Administrator. Note: RDS is intended for development use only."
How can I deal with this, any idea? Is it possible to do without enabling RDS?
Please let me know if you know something about this, I will be really grateful.
You can create a webservice for WSDL. Here I'm going to taken an some real time demo url http://www.dneonline.com/calculator.asmx?wsdl & Coldfusion 2018. Please follow the below steps.
Step 1 : Create webservice in CFAdmin - > Data & Service - > Webservices
Step 2 : Give the Webservice name & WSDL URL value. Refer my image here (TestService.png) I've created 'TestService' for the url http://www.dneonline.com/calculator.asmx?wsdl.
Step 3 : Once you added it successfully. You can able to see that in "Active Coldfusion WebService Options"
Step 4 : With the help of createObject method & webservice value you can call your all methods in your WSDL url. For example,
<cfset myObj = createObject('webservice','TestService')>
<cfdump var='#myObj#' abort="true">
Step 5 : You can see my below dump about demo webservice url Methods & Classes. Refer image dumpService.png
I hope this will help you to know about simple Webservice.
I am stuck with Apache Camel. I need to expose an web service through JBOSS FUSE, but the payload that I must return depends on call to two external web services.
So, the first external web service has this URL:
http://someip/externalWSOne
This receive one param named A, and return three values X, Y and Z.
The second one, receive three params named B, X and Y. Notice that X and Y are the returned values from first external web service.
http://someip/externalWSTwo
This second external web service return N1...Nn values that are the final payload
The final user consume only one web service, that is the internal we service that I will expose through JBOSS FUSE. For this reason I need to expose a web service that receive two params
What is the correct way to model this flow in Apache camel? I write the following configuration but the final payload are empty:
<cxf:cxfEndpoint id="epInterno" address="/ep-interno/" serviceClass="somePackage.MyWebServiceInterface">
<cxf:cxfEndpoint id="epExterno1" address="http://someip/externalWSOne" serviceClass="somePackage.ExternalWSOneServiceInterface">
<cxf:cxfEndpoint id="epExterno2" address="http://someip/externalWSTwo" serviceClass="somePackage.ExternalWSTwoServiceInterface">
<camelContext id="blueprintContext" trace="false" xmlns="http://camel.apache.org/schema/blueprint">
<route id="ruta1">
<from uri="cxf:bean:epInterno"/>
<process ref="proccesorOne" />
<to uri="cxf:bean:epExterno1" />
<process ref="processorTwo" />
<to uri="cxf:bean:epExterno2" />
</route>
</camelContext>
All artifacts for external web services are generate with Maven plugin.
Ok, I tried probe my solution so I decided to write the three projects mentioned above.
THE RESULT: YES this is the correct way *
Seems that for my case, when I use the real WS, I have problems not strict related with apache camel flow, instead of this are related with the implementation of this external WS
So, if I somebody need to test by self, can try it analyzing the following code for projects in github.
https://github.com/pazfernando/apache-camel-multi-ws_externalWSOne
https://github.com/pazfernando/apache-camel-multi-ws_externalWSTwo
https://github.com/pazfernando/apache-camel-multi-ws_test-fuse-ws
Thanks
Hello!
I'm trying to learn some Apache Camel and Apache CXF and of course I've ran into some problems.
What I'm trying to do:
Send timed SOAP messages from ESB to some web service, wait for the reponse from the web service and process it. I'm using Apache ServiceMix!.
What I've done:
Implemented a WSDL file with two operations PingOutput (what I'm sending) and PingInput (what I want to receive from the WS).
Implemented a CXF Endpoint (http://127.0.0.1:8090/ping_ws is a WS mocked with SoapUI):
<cxf:cxfEndpoint address="http://127.0.0.1:8090/ping_ws"
id="Ping_Mocked_WS" wsdlURL="ping.wsdl">
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD" />
</cxf:properties>
</cxf:cxfEndpoint>
Implemented a Camel route:
<camelContext xmlns="http://camel.apache.org/schema/spring" streamCache="true">
<route id="ping-ws">
<from uri="timer://ping_timer?fixedRate=true&period=10000"/>
<bean ref="PingBean" method="createPingRequest" />
<to uri="cxf:bean:Ping_Mocked_WS"/>
<bean ref="PingBean" method="processPingResponse" />
</route>
</camelContext>
What I do not understand:
Why the <bean ref="PingBean" method="processPingResponse" /> gets the correct response from SoapUI (the PingOutput operation defined in WSDL)?
Is this the correct way to achieve my goal? And by this way I mean with one single route?
The codes work correctly, I might have some typos here, please do not mind them.
Thanks!
Ad 1)
Likely because the type defined in the method signature of the processPingResponse method. Camel uses bean parameter binding, and based on the type, it uses its type converter to convert to the given type.
And as the payload is a SOAP response in XML it can use JAXB to convert from XML to the type from the method signature.
To do so it uses camel-jaxb which ServiceMix comes with out of the box.
Ad2)
The route works. What it is you want to do differently?
I am developing a Web service using Apache CXF and contract first approach with schema validation. Problem is, that validation is not working. There is no error, so it like is not activated. But validation is configured.
So, I have took a look to official Apache CXF examples you can find here.
I took a look to wsdl_first example and modify it adding schema validation and some restriction in WSDL:
<!-- HTTP Endpoint -->
<jaxws:endpoint xmlns:customer="http://customerservice.example.com/"
id="CustomerServiceHTTP" address="http://localhost:9090/CustomerServicePort"
serviceName="customer:CustomerServiceService" endpointName="customer:CustomerServiceEndpoint"
implementor="com.example.customerservice.server.CustomerServiceImpl">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" />
</jaxws:features>
<!-- schema validation-->
<jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties>
</jaxws:endpoint>
To my surprise, it doesn't work either.
OK, so I took a look to wsdl_first_xmlbeans example, where according with the README.txt file, it also shows how CXF configuration can be used to enable schema validation.
And for this example, schema validation works. The difference between both examples is that the second one use JAX-WS APIs and with the XMLBeans approach. Does it have something to do? Why schema validation is not working for first example? Probably, I am missing something.
For validation on the service side, it would likely need to have a wsdlLocation attribute set on the jaxws:endpoint so it would load the WSDL (that would then contain the schemas). Currently, the validation in that example is on the client side only. If you run the service, the log shows:
INFO: Creating Service {http://server.customerservice.example.com/}CustomerServiceImplService from class com.example.customerservice.CustomerService
which shows it's not using the WSDL at all.
On CF 9.01, Windows Web Server 2008 R2, a web service has stopped running here, so I'm trying to figure out the problem. I think the problem may have started when I applied the 9.01 hotfix.
I added a test.cfc to the server
<cfcomponent output="false">
<cffunction
name = "echoString"
output = "no"
access = "remote" returntype="any">
<cfargument required="true" name="inputString" type="string"/>
<cfreturn arguments.inputString>
</cffunction>
</cfcomponent>
and call it with
<cfinvoke webservice="https://nww.somedomain.nhs.uk/cfcs/test.cfc?wsdl"
method="echoString" returnvariable="returnedString">
<cfinvokeargument name="inputString" value="test string 2">
</cfinvoke>
and get the string response, but in the cf administrator the web service is not being added
when I invoke the web service for the first time as I think it should be.
Other than reinstalling CF or trying to roll back manually, any clues as to the problem or how I can test please?
I'm on 9,0,1,274733 . The https is not the problem I think. Firstly it was working fine then with no change to code it stopped. Secondly my test invocation of test.cfc works as expected over https.
If I hit https://nww.somedomain.nhs.uk/cfcs/test.cfc?wsdl (which works) or my problem cfc https://nww.somedomain.nhs.uk/cfcs/providerapi.cfc?wsdl directly in the browser they both correctly show the XML details.
However, invoking either of the CFCs does not add them to the active web services list in administrator.
I pasted the "echostring" method to my problem CFC (providerapi.cfc) and tried calling the method but I get a "webservice cannot be found" error. It's like the providerapi.cfc is cached , but I can't see it in administrator to delete it.
I tried this verbatim on 9,0,1,274733 and it worked 100% fine. I am using Win 7 and I just tried it on my dev environment. The web service was added to the list in CF admin so you are correct to expect that.
Can you ensure that you can hit the URL direct (i.e. https://nww.somedomain.nhs.uk/cfcs/test.cfc?wsdl) in your browser and view source to see the WSDL XML?
One thing that jumps out is the use of https:// in your web service invocation. Can you try it with just http:// or even better against your localhost?