Last active
September 6, 2015 12:02
-
-
Save bardware/36385fe3abf870540f61 to your computer and use it in GitHub Desktop.
SOAP web service with optional arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- http://stackoverflow.com/questions/32385955/soap-web-service-with-optional-arguments?noredirect=1#comment52650901_32385955 ---> | |
<cfcomponent output="false"> | |
<cffunction name="myFunc" returntype="struct" access="remote"> | |
<cfargument name="mParam" type="numeric" required="true"> | |
<cfargument name="oParam" type="string" required="false" default="strDefault"> | |
<cfreturn Arguments> | |
</cffunction> | |
</cfcomponent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- only works when both cfinvokeargument tags are present ---> | |
<cfinvoke method="myFunc" webservice="http://tester002/webservice.cfc?wsdl" returnvariable="ws"> | |
<cfinvokeargument name="mParam" value="1"> | |
<cfinvokeargument name="oParam" value="1"> | |
</cfinvoke> | |
<cfdump var="#ws#"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// works if only one argument is present | |
$requestParams = array( | |
'mParam' => 2 | |
); | |
try { | |
$client = new SoapClient('http://tester002/webservice.cfc?wsdl'); | |
$response = $client->myFunc($requestParams); | |
print_r($response); | |
} catch( Exception $ex ) { | |
var_dump( $ex ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' works if only one parameter is set | |
Public Class Form1 | |
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click | |
Dim c = New webservice001.webservice.webservicecfcPortTypeClient("webservice.cfcHttpSoap12Endpoint") | |
Dim r As New webservice001.webservice.myFuncRequest | |
r.mParam = 1 | |
Dim resp = c.webservice_webservicecfcPortType_myFunc(r) | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment