小编Che*_*ter的帖子

ColdFusion CFC CORS和AJAX帖子

我正在尝试将表单发布到远程服务器.目前,一般的想法是HTML将在本地运行,并将通过AJAX发布到远程服务器.

所以有一个表格,JS和它发布的CFC.

以下是JS

$(document).ready(function () {
$("#submit").click(function(){
    var setName = $("input[name='setName']").val();
    var setNumber = $("input[name='setNumber']").val();
    var setTheme = $("input[name='setTheme']").val();

    var retailPrice = $("input[name='retailPrice']").val();
    var purchaseStore = $("input[name='purchaseStore']").val();
    var purchaseDate = $("input[name='purchaseDate']").val();
    var purchasePrice = $("input[name='purchasePrice']").val();

    var condition = $("input[name='condition']").val();

    var sellPrice = $("input[name='sellPrice']").val();
    var sellStore = $("input[name='sellStore']").val();
    var selldate = $("input[name='selldate']").val();

$.ajax({
    type: 'get',
    url: 'http://www.chesteraustin.us/cfc/entry.cfc?ReturnFormat=json',  
    data: {
        method: 'setEntry',
        Set_Name: setName, //CFARGUMENT: JS_VARIABLE
        Set_Number: setNumber,
        Set_Theme: setTheme,
        Retail_Price: retailPrice,
        Purchase_From: purchaseStore,
        Purchase_Price: purchasePrice,
        Purchase_Date: purchaseDate,
        Status: condition,
        Sell_Date: sellPrice, …
Run Code Online (Sandbox Code Playgroud)

javascript ajax coldfusion jquery cors

8
推荐指数
1
解决办法
3649
查看次数

WCF和ColdFusion

我有一个WCF WebService我想使用ColdFusion消费.常规过程是使用CFHTTP在WSDL中使用SOAP请求.通常,这是有效的,一切正常.

<cfsavecontent variable="xmlBody" >
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
   <soap:Header/>
   <soap:Body>
      <tem:GetVersion/>
   </soap:Body>
</soap:Envelope>
</cfsavecontent>
Run Code Online (Sandbox Code Playgroud)
<cfhttp url="https://www.example.com/OtherService.svc?wsdl" method="post" timeout="1200" username="myUsername" password="myPassword" >
    <cfhttpparam type="header" name="Content-Type" value="application/soap+xml;charset=UTF-8">
    <cfhttpparam type="header" name="Content-Length" value="#len(trim(xmlbody))#">
    <cfhttpparam type="header" name="soapAction" value="http://tempuri.org/GetVersion">
    <cfhttpparam type="body" name="body" value="#trim(xmlBody)#">
</cfhttp>
<cfdump var="#cfhttp#">
Run Code Online (Sandbox Code Playgroud)

运行页面后,我得到了The security context token is expired or is not valid. The message was not processed.回复.在阅读服务提供商提供的文档时,似乎我不能只将XML发布到URL并将其称为一天: While WCF uses XML to post communications to the endpoint, it is required that users use Visual Studio's "Add Service Reference" or svcutil.exe …

.net coldfusion wcf web-services coldfusion-11

6
推荐指数
0
解决办法
388
查看次数

AngularJS和ColdFusion CFC

我正在尝试使用ColdFusion后端接收AngularJS,并遇到了一些障碍.我正在使用CF Art Gallery数据库修改他们的"To Do"应用程序http://angularjs.org/.我正在尝试使用AJAX将ColdFusion CFC链接到Angular应用程序.

以下是我的artists.cfc:

<cfcomponent>

<cffunction name="getArtists" access="remote" >
    <cfargument name="firstName" default="">
    <cfargument name="lastName" default="">

    <cfquery name="getArtists_sql" datasource="cfartgallery">
        SELECT
            firstname as text,
            lastname as done 
        FROM artists
        WHERE 0=0
    <cfif firstName neq "">
        AND ucase(firstname) like ucase('%#FIRSTNAME#%')
    </cfif>
    <cfif lastName neq "">
        OR ucase(lastname) like ucase('%#LASTNAME#%')       
    </cfif>
    </cfquery>

    <cfreturn getArtists_sql>
</cffunction>

</cfcomponent>
Run Code Online (Sandbox Code Playgroud)

我使用AngularJS使用以下代码调用CFC:

function TodoCtrl($scope, $http) {
    $http.get('cfc/artists.cfc?method=getArtists&returnformat=json').
        success(function (response) {
            $scope.todos = data.DATA;
    }).
        error(function (data) {
            $scope.todos = data;
        });
}
Run Code Online (Sandbox Code Playgroud)

我知道我得到了回复.以下是Chrome的开发者工具为我返回的JSON字符串:

{
"COLUMNS": …
Run Code Online (Sandbox Code Playgroud)

coldfusion cfc angularjs

5
推荐指数
1
解决办法
5267
查看次数

在ColdFusion中传递Java对象

这是该问题的延续:WCF和ColdFusion

因此,我设法使用Metro并导入WSDL来使JAR正常工作。我的主类具有以下功能:getVersion()和实现myVersion()cancelOrder()以及myCancel()和,最后placeOrder还有和myOrder()

各种方法

对于前两种方法(getVersioncancelOrder),我能够传递正确的信息并从Web服务获得响应:

例如,在myVersion方法中,它调用Web服务并输出版本号和传递的字符串:

<cfset var.myVersion = createObject("java", "com.USOrlando").myVersion(
    javaCast("string", "Batman")
)>
<!---Output is [version number] + "I'm Batman" --->
Run Code Online (Sandbox Code Playgroud)

使用相同的模板,我还可以传递myOrder方法中除type的最后一个参数以外的所有其他参数org.tempuri.ArrayOfSmartOrderLineRequest

这是我不确定的地方,可能需要指导:

在阅读文档和生成的类时,我将在文档中用引号引起来,以及如何理解它们。

myOrder应该采用通过ColdFusion传递的所有参数并将其放入request对象中。

<cfset var.01_00_myOrder = createObject("java", "com.USOrlando").myOrder(
    JavaCast("String", ExternalOrderId),
    JavaCast("int", CustomerID),
    .
    .
    .
    JavaCast("String", Phone),
    JavaCast("String", Email),
    JavaCast("org.tempuri.ArrayOfSmartOrderLineRequest", orderItems)
)>
Run Code Online (Sandbox Code Playgroud)

最后一行JavaCast("org.tempuri.ArrayOfSmartOrderLineRequest", orderItems)是我的问题。我得到一个

JavaCast类型org.tempuri.ArrayOfSmartOrderLineRequest必须是以下类型之一:字节,字符,短型,整数,长型,浮点型,双精度型,布尔型,字符串,大十进制,其对应的数组表示形式(例如:int [])或null。

错误,这是有道理的。如果将其放入null,则任何内容都不会传递到SoapMessage中。

我的问题是:如何传递最终参数? …

java coldfusion jar coldfusion-11

5
推荐指数
1
解决办法
773
查看次数

标签 统计

coldfusion ×4

coldfusion-11 ×2

.net ×1

ajax ×1

angularjs ×1

cfc ×1

cors ×1

jar ×1

java ×1

javascript ×1

jquery ×1

wcf ×1

web-services ×1