对WebService和WSDL比较了解的进来帮助一下

hwj383 2011-07-21 10:59:40
场景:
有两线上网站A和调,其中A调用B提供的WebService服务.
因为某种原因,B不能继续提供服务.

要求:现要求用一服务来完全替代B提供的服务.

限制:A网站不能动,除了配置文件中的WebService地址可变化,其它不能有什么何变化.

可用资源:
1.一个A的本地源代码,已确定和线上A网站运行版本不一致,其中有一个调用B服务生成的本地代理和1个WSDL文件
2.一个线上的A网站COPY(发布版本,非源代码,可反编译,未混淆,可在本地WebServer运行)

已尝试:使用Wsdl.exe 对wsdl文件生成服务器端代码(接口),并实现.提供服务.
在使用Wsdl有一个error(具体请Wsdl.exe /si "path")

把本地A网站配置到新地址,debug可以发现,能够调入到新的服务并正确执行,也能返回结果,
但是在A接收到NULL.

在 代理类中方法中: object[] results = this.Invoke("method", new object[]{in0,in1});
results为Null,但是服务端已输出了结果(debug可知,或直接测试服务也可知)


已检查:服务器生成的接口和实现的XML特性的namespace和反编译(线上A)的代理的XML的namespace.

请大家畅所欲言,有能帮助者至少200分,QQ282092961

附:WSDL

...全文
269 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
victory1124 2011-11-23
  • 打赏
  • 举报
回复
我也很迷惑……
zhaofucai0830 2011-08-01
  • 打赏
  • 举报
回复
ding.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~接分!
「已注销」 2011-07-25
  • 打赏
  • 举报
回复
学习
学习
学习
学习
学习
学习
学习
学习
zhouxingyu896 2011-07-24
  • 打赏
  • 举报
回复
学习
学习
「已注销」 2011-07-22
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 sp1234 的回复:]
哦当然啦,在你的新的服务器程序上先引入这个WSDL文件生成所谓的客户端代理程序,然后按照上面说的去修改,相信用不了几十分钟就能整理出一个完整的服务端代码(当然不包括功能实现)。
[/Quote]

我咋日已经根据客户端源代码和WDSL文件整理出了一份服务器端的定义(见我的已尝试描述节),当然和您10楼整理的无太大差异.并且A能调用新的服务.

如果是仅仅整理出方法和必需的实体信息估计是不够的.因为在服务器端实体类和方法上有[反]序列化特性标记(主要是XmlAttribute),客户端在生成代理和反序化时肯定要依据这些信息,如namespace等.
我也尝试检查了客户端生成代理信息的特性标记,因为反编译出来的不是很全(有些特性标记不全[或是本来就是这样]),和服务器端的定义比较了一下,问题不大(服务器端是通过Wsdl生成的)
「已注销」 2011-07-22
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 hwj383 的回复:]
引用 6 楼 dongxinxi 的回复:
又看了一下你的帖子,那么目前可以确定的是,你的代理类是没有问题的
调到了服务,并且服务端返回了数据,并不代理服务端返回的数据(XML)结构是代理能够正确解析的
建议:将你生成的服务WSDL和你之前的WSDL用代码对比工具进行差异对比(肉眼估计会累死你)


这一步已经估过,是有一些不一致,因为B源WebService提供了大量WebMetho……
[/Quote]

另外我认为这种不一致不会影响结果,因为返回的XML文件反序列化所需要的所有相关信息均在代理中定义.
「已注销」 2011-07-22
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 dongxinxi 的回复:]
又看了一下你的帖子,那么目前可以确定的是,你的代理类是没有问题的
调到了服务,并且服务端返回了数据,并不代理服务端返回的数据(XML)结构是代理能够正确解析的
建议:将你生成的服务WSDL和你之前的WSDL用代码对比工具进行差异对比(肉眼估计会累死你)
[/Quote]

这一步已经估过,是有一些不一致,因为B源WebService提供了大量WebMethod,而我新服务只提供了A要调用的必需方法,这个可能是造成WSDL文件不一致的原因.

  • 打赏
  • 举报
回复
例如说
    public class Weather
{

public RespInfo updateWeatherInfo(InfoHeader in0, WeatherInfoBean in1)
{
throw new NotImplementedException();
}

public RespInfo2someListMap findWeatherInfoList(InfoHeader in0, NetWorkConditions in1)
{
throw new NotImplementedException();
}

public RespInfo addWeatherInfo(InfoHeader in0, WeatherInfoBean in1)
{
throw new NotImplementedException();
}
}

public partial class WeatherInfoBean
{

public string agriTips{get;set;}

public string cdbId{get;set;}

public string cpId{get;set;}

public string day{get;set;}

public string forecastDate{get;set;}

public string humidity{get;set;}

public string pubDate{get;set;}

public string recordStatus{get;set;}

public string region{get;set;}

public string source{get;set;}

public string status{get;set;}

public string temperature{get;set;}

public string weather{get;set;}

public string windDirection{get;set;}

public string windSpeed{get;set;}

}

将原来的客户端代理程序源代码中的这两个类,跟我删减之后的做个对比,你就完全明白了!
  • 打赏
  • 举报
回复
哦当然啦,在你的新的服务器程序上先引入这个WSDL文件生成所谓的客户端代理程序,然后按照上面说的去修改,相信用不了几十分钟就能整理出一个完整的服务端代码(当然不包括功能实现)。
  • 打赏
  • 举报
回复
既然你可以反编译,那么拿出A的有关服务客户端代理里边的代码,是数据的class就用数据的class,是功能调用的class就把它有关
:System.ServiceModel.ClientBase<W>,....
父类声明删掉,再把几个实例化方法删掉,剩下功能调用的声明代码。

这就有了完全没有问题的服务器端声明的源代码!而不用看WSDL文本。
  • 打赏
  • 举报
回复
并不代表服务端返回的数据(XML)结构是代理能够正确解析的
  • 打赏
  • 举报
回复
又看了一下你的帖子,那么目前可以确定的是,你的代理类是没有问题的
调到了服务,并且服务端返回了数据,并不代理服务端返回的数据(XML)结构是代理能够正确解析的
建议:将你生成的服务WSDL和你之前的WSDL用代码对比工具进行差异对比(肉眼估计会累死你)
「已注销」 2011-07-21
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 dongxinxi 的回复:]
不太明白这句话的意思:
在 代理类中方法中: object[] results = this.Invoke("method", new object[]{in0,in1});
results为Null,但是服务端已输出了结果(debug可知,或直接测试服务也可知)

用工具直接生成的代理类,注意nillable="true"表示该字段为可空类型
[XmlElement(IsNullabl……
[/Quote]
嗯,Nullable表示可空,关键是服务器返回的不为NULL,只能用C#.
  • 打赏
  • 举报
回复
另外可以尝试第三方的工具,比如SoapUI 4.0,代码类别选择C#
  • 打赏
  • 举报
回复
不太明白这句话的意思:
在 代理类中方法中: object[] results = this.Invoke("method", new object[]{in0,in1});
results为Null,但是服务端已输出了结果(debug可知,或直接测试服务也可知)

用工具直接生成的代理类,注意nillable="true"表示该字段为可空类型
[XmlElement(IsNullable = true)]
「已注销」 2011-07-21
  • 打赏
  • 举报
回复
<xsd:complexType name="someList">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="WeatherInfoBean" nillable="true" type="ns2:WeatherInfoBean" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="findWeatherInfoListResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="out" nillable="true" type="tns:RespInfo2someListMap" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="addWeatherInfo">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="in0" nillable="true" type="ns1:InfoHeader" />
<xsd:element minOccurs="1" maxOccurs="1" name="in1" nillable="true" type="ns2:WeatherInfoBean" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="addWeatherInfoResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="out" nillable="true" type="ns1:RespInfo" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="findWeatherInfoListResponse">
<wsdl:part name="parameters" element="tns:findWeatherInfoListResponse" />
</wsdl:message>
<wsdl:message name="findWeatherInfoListRequest">
<wsdl:part name="parameters" element="tns:findWeatherInfoList" />
</wsdl:message>
<wsdl:message name="addWeatherInfoResponse">
<wsdl:part name="parameters" element="tns:addWeatherInfoResponse" />
</wsdl:message>
<wsdl:message name="addWeatherInfoRequest">
<wsdl:part name="parameters" element="tns:addWeatherInfo" />
</wsdl:message>
<wsdl:message name="updateWeatherInfoRequest">
<wsdl:part name="parameters" element="tns:updateWeatherInfo" />
</wsdl:message>
<wsdl:message name="updateWeatherInfoResponse">
<wsdl:part name="parameters" element="tns:updateWeatherInfoResponse" />
</wsdl:message>
<wsdl:portType name="WeatherInfoManagerWSS4JEncSignServicePortType">
<wsdl:operation name="updateWeatherInfo">
<wsdl:input name="updateWeatherInfoRequest" message="tns:updateWeatherInfoRequest" />
<wsdl:output name="updateWeatherInfoResponse" message="tns:updateWeatherInfoResponse" />
</wsdl:operation>
<wsdl:operation name="findWeatherInfoList">
<wsdl:input name="findWeatherInfoListRequest" message="tns:findWeatherInfoListRequest" />
<wsdl:output name="findWeatherInfoListResponse" message="tns:findWeatherInfoListResponse" />
</wsdl:operation>
<wsdl:operation name="addWeatherInfo">
<wsdl:input name="addWeatherInfoRequest" message="tns:addWeatherInfoRequest" />
<wsdl:output name="addWeatherInfoResponse" message="tns:addWeatherInfoResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WeatherInfoManagerWSS4JEncSignServiceHttpBinding" type="tns:WeatherInfoManagerWSS4JEncSignServicePortType">
<wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="updateWeatherInfo">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="updateWeatherInfoRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="updateWeatherInfoResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="findWeatherInfoList">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="findWeatherInfoListRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="findWeatherInfoListResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="addWeatherInfo">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="addWeatherInfoRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="addWeatherInfoResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WeatherInfoManagerWSS4JEncSignService">
<wsdl:port name="WeatherInfoManagerWSS4JEncSignServiceHttpPort" binding="tns:WeatherInfoManagerWSS4JEncSignServiceHttpBinding">
<wsdlsoap:address location="http://218.206.4.8:9090/cdbim/services/WeatherInfoManagerWSS4JEncSignService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
「已注销」 2011-07-21
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:tns="http://interfaces.server.services.cdbim.com" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://bean.server.services.cdbim.com" xmlns:ns1="http://msg.common.server.services.cdbim.com" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" targetNamespace="http://interfaces.server.services.cdbim.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://msg.common.server.services.cdbim.com">
<xsd:complexType name="InfoHeader">
<xsd:sequence>
<xsd:element minOccurs="0" name="code" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="password" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="serverId" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="sourceCode" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="timestamp" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="RespInfo">
<xsd:sequence>
<xsd:element minOccurs="0" name="respCode" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="respMessage" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://bean.server.services.cdbim.com">
<xsd:complexType name="WeatherInfoBean">
<xsd:sequence>
<xsd:element minOccurs="0" name="agriTips" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="cdbId" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="cpId" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="day" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="forecastDate" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="humidity" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="pubDate" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="recordStatus" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="region" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="source" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="status" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="temperature" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="weather" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="windDirection" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="windSpeed" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="NetWorkConditions">
<xsd:sequence>
<xsd:element minOccurs="0" name="strSearch" nillable="true" type="tns:ArrayOfString" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://interfaces.server.services.cdbim.com">
<xsd:element name="updateWeatherInfo">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="in0" nillable="true" type="ns1:InfoHeader" />
<xsd:element minOccurs="1" maxOccurs="1" name="in1" nillable="true" type="ns2:WeatherInfoBean" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="updateWeatherInfoResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="out" nillable="true" type="ns1:RespInfo" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="ArrayOfString">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="findWeatherInfoList">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="in0" nillable="true" type="ns1:InfoHeader" />
<xsd:element minOccurs="1" maxOccurs="1" name="in1" nillable="true" type="ns2:NetWorkConditions" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="RespInfo2someListMap">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="entry">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="1" name="key" type="ns1:RespInfo" />
<xsd:element minOccurs="0" maxOccurs="1" name="value" type="tns:someList" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧