有人能告诉我Colfusion 8是否可以使用WCF服务吗?
我找不到任何适合这种情况的好例子 此外,WCF服务使用实体框架6.0,该框架应返回大JSON结构。 现在,我只是想找到一个简单的例子,可以调用一个简单的WCF服务:有人能告诉我Colfusion 8是否可以使用WCF服务吗?,wcf,coldfusion,Wcf,Coldfusion,我找不到任何适合这种情况的好例子 此外,WCF服务使用实体框架6.0,该框架应返回大JSON结构。 现在,我只是想找到一个简单的例子,可以调用一个简单的WCF服务: [ServiceContract] public interface ITest { [OperationContract(Name = "Test_GetDate")] [WebGet(UriTemplate = "/GetDate", RequestFormat = WebMessageFormat.Json,
[ServiceContract]
public interface ITest
{
[OperationContract(Name = "Test_GetDate")]
[WebGet(UriTemplate = "/GetDate", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string GetDate();
...
public class Test : ITest
{
public string GetDate()
{
return (DateTime.UtcNow.ToString());
}
...
谢谢可以。这个场景对我很有用,但我使用的是XML格式(WCFSOAP)而不是rest/json,但您可以试试 -我使用SOAPUI来计算soap信封的外观。此工具免费且易于使用 -创建新的Soap UI项目并在输入中粘贴WSDL地址,应用程序将生成空的XML请求-Soap信封 -您可以从此应用程序测试您的服务 -我正在使用cfhttp从cf调用服务: 我们算出了soap信封,并将其放入cf变量中:
<cfsavecontent variable="soapBody">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:ozon="http://schemas.datacontract.org/blah/prc">
<soapenv:Header/>
<soapenv:Body>
<tem:myservicemethod>
<tem:someParameter1>This is my first param</tem:someParameter1>
<tem:someParameter2>
<blah:AC>This is my second parameter</blah:AC>
</tem:someParameter2>
</tem:myservicemethod>
</soapenv:Body>
</soapenv:Envelope>
</cfsavecontent>
这是我的第一个情人
这是我的第二个参数
现在调用服务。这是我从Ben Nadel的博客中挖掘出来的:
您是否尝试过使用cfinvoke
或createbject()
点击WSDL?这里是一些信息-这里是一个例子:我得到下面的错误(我可以通过下面的IP浏览服务):java.util.NoSuchElementException:null错误发生在D:\WebSites\Coldfusion\test\test.cfm:line 7 5:webservice=”“6:method=“GetDate”7:returnvariable=“response”8:>9:听起来你缺少了一个必需的参数。你是说我需要为我调用的每个服务或方法构建一个SOAP信封吗?另外,我不想返回XML,WCF设置为返回JSON。。。。有人帮我,因为我找不到关于这个话题的好文章/博客感谢您不需要,因为服务将无法解析它。您的web请求定义您正在发送JSON,因此请求的内容只能是JSON。我会尝试使用soap ui或一些类似的工具来测试web服务(),以确定我需要在主体中发送什么,然后我会使用这种cfhttp方法。
<cfhttp
url="http:/SomeService/Service.svc"
method="post"
result="httpResponse">
<!---
TIP : Look into your WSDL to figure out SOAPAction value
--->
<cfhttpparam
type="header"
name="SOAPAction"
value="http://tempuri.org/SomeService/myservicemethod"
/>
<cfhttpparam
type="header"
name="accept-encoding"
value="no-compression"
/>
<cfhttpparam
type="xml"
value="#trim( soapBody )#"
/>
</cfhttp>
<cfdump var="#httpResponse#" />