首先写一个简单的webservice:
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld(string name) {
return "Hello, " + name;
}
}
在RoR项目里,添加app/apis/test_api.rb:
class TestApi < ActionWebService::API::Base
api_method :HelloWorld, :expects => [{:name => :string}], :returns => [:string]
end
这是RoR里面通用的webservice元信息描述。
添加app/controllers/test_controller.rb:
class TestController < ApplicationController
web_client_api :test, :soap, "http://localhost/test/Service.asmx",
:namespace => "http://tempuri.org/",
:soap_action_base => "http://tempuri.org",
:driver_options=>{:default_encodingstyle => SOAP::EncodingStyle::ASPDotNetHandler::Namespace }
def hello
render_text test.HelloWorld("Li Jie")
end
end
:soap_action_base选项是一个修补,不加这个选项会产生SOAPAction头错误。
运行服务器,在浏览器中访问/test/hello,发现名字为空。经过长时间调试,发现.Net在解析SOAP消息体时,不能处理这种命名空间:
<n1:HelloWorld xmlns:n1="http://tempuri.org/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<name xsi:type="xsd:string">Li Jie</name>
</n1:HelloWorld>
把n1去掉就行了。不过这部分实现在rubylib/soap/rpc/proxy.rb里面,实在不方便修改。为了让这个测试通过,暂时做了点小修改:
def route(req_header, req_body, reqopt, resopt)
req_env = ::SOAP::SOAPEnvelope.new(req_header, req_body)
unless reqopt[:envelopenamespace].nil?
set_envelopenamespace(req_env, reqopt[:envelopenamespace])
end
reqopt[:external_content] = nil
conn_data = marshal(req_env, reqopt)
if ext = reqopt[:external_content]
mime = MIMEMessage.new
ext.each do |k, v|
mime.add_attachment(v.data)
end
mime.add_part(conn_data.send_string + "\r\n")
mime.close
conn_data.send_string = mime.content_str
conn_data.send_contenttype = mime.headers['content-type'].str
end
conn_data.send_string.gsub!(/:n1/, '')
conn_data.send_string.gsub!(/n1:/, '')
conn_data = @streamhandler.send(@endpoint_url, conn_data,
reqopt[:soapaction])
if conn_data.receive_string.empty?
return nil
end
unmarshal(conn_data, resopt)
end
加粗的2行是我添加的代码,勉强可以让它工作,不过显然不是正确的方法。
不知道是不是.Net库里面的BUG。
相关推荐
ror中文资料ror中文资料
RoR ActiveRecord style syntax Ambient transaction Dynamic object Partial update 1:1 1:Many Many:Many relations Auto create table Anti sql injection Multiple data source Object validation ...
ror实例ror实例ror实例
RoR性能优化经验谈,牛人对ror的优化,值得大家阅读
之前本人在windows 上搭建ROR环境,屡屡受挫,上网查资料、加入ruby on rails的qq群,关注ruby社区等,没有得到一套完整的正确的方法,很多朋友说不要在windows 弄ROR,很费力。的确很费力,后来在朋友的帮助下,...
家蚕Ror2基因的克隆与表达分析,刘伟,陈菲,Ror家族属于受体酪氨酸激酶中的孤儿受体,在进化上非常保守。本研究克隆了家蚕Ror2基因BmRor2的ORF序列,BmRor2基因的ORF为1924 bp,编码638
基于RoR的博客系统,代码风格简单清晰,前后太完善,适合初学者。
ROR 架构介绍及了解
RoR选题方向—源代码
NULL 博文链接:https://xuxiangpan888.iteye.com/blog/266696
神经网络ror resenet模型 cifar10准确率89% cifar100准确率72%
asp.net 支持断点续传,大文件上传
ROR环境 Ruby version 1.9.3 (java) RubyGems version 1.8.24 Rack version 1.4 Rails version 3.2.12 JavaScript Runtime therubyrhino (Rhino) Active Record version 3.2.12 Action Pack version 3.2.12 ...
插件,可以不用到那个网站上去下了,还有mysql-front备份文件,大家可以直接导入。 博文链接:https://msdn.iteye.com/blog/44807
mysqlDriver4ror.rarmysqlDriver4ror.rarmysqlDriver4ror.rarmysqlDriver4ror.rar
研究机构注册(ROR)API ROR API允许检索,搜索和过滤在ROR中建立索引的组织。 结果以JSON返回。 单个组织记录由以下JSON结构表示: { "id":"https://ror.org/013cjyk83", "name":"PSL Research University", "email...
Source.Insight.v3.50.0027-ROR.rar
破解版本的JAR包,放到本地磁盘,ECLIPUS直接用,到JVM设置直接加 -noverify -javaagent:D:\javarebel.jar
NULL 博文链接:https://shouaya.iteye.com/blog/690444
我自己再开发时的笔记