Webservice 可与 SoapSonar 一起使用,但不能与 Visual Studio Winform 一起使用 [英] Webservice works with SoapSonar but not with Visual Studio Winform

查看:42
本文介绍了Webservice 可与 SoapSonar 一起使用,但不能与 Visual Studio Winform 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将响应格式更改为类似于 VS 并且错误现在是无法识别消息版本"

Changed Response format to be like VS and error is now "Message Version not recognized"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <DiscordianResponse xmlns="http://reboltutorial.com/">
      <DiscordianResult>Sweetmorn, Discord 48, Year of Our Lady of Discord 3176</DiscordianResult>
    </DiscordianResponse>
  </soap:Body>
</soap:Envelope>

我用这里的 Visual Studio 生成了一个 wsdl 文件;http://reboltutorial.com/webservices/discordian.wsdl

I have generated a wsdl file with Visual Studio which is here; http://reboltutorial.com/webservices/discordian.wsdl

实现是一个 cgi 而不是 .net 框架程序,但这应该无关紧要,因为它是网络服务的目的.

Implementation is a cgi instead of a .net framework program but that should not matter as it is the purposes of webservices.

我用 SoapSonar 测试成功:

I tested it successfully with SoapSonar:

http://reboltutorial.com/images/soapsonar.png

但是在 Visual Studio 下它失败了,代码如下:

But under Visual Studio it fails with this code:

private void button1_Click(object sender, EventArgs e)
{
    RebolTutorial.ServiceSoapClient Discordian = new RebolTutorial.ServiceSoapClient("ServiceSoap");
    int year = int.Parse(this.year.Text);
    int month = int.Parse(this.month.Text);
    int day = int.Parse(this.day.Text);
    response.Text = Discordian.Discordian(year,month,day);
}

你能看到什么原因?谢谢.

Any reason you can see ? Thanks.

请求如下:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://reboltutorial.com/">
  <soap:Body>
    <tns:Discordian>
      <tns:year>2010</tns:year>
      <tns:month>5</tns:month>
      <tns:day>1</tns:day>
    </tns:Discordian>
  </soap:Body>
</soap:Envelope>

以及 WSDL(如果需要):

as well as WSDL if needed:

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://reboltutorial.com/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://reboltutorial.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://reboltutorial.com/">
      <s:element name="Discordian">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" name="year" type="s:int" />
            <s:element minOccurs="1" maxOccurs="1" name="month" type="s:int" />
            <s:element minOccurs="1" maxOccurs="1" name="day" type="s:int" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="DiscordianResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="DiscordianResult" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:schema>
  </wsdl:types>
  <wsdl:message name="DiscordianSoapIn">
    <wsdl:part name="parameters" element="tns:Discordian" />
  </wsdl:message>
  <wsdl:message name="DiscordianSoapOut">
    <wsdl:part name="parameters" element="tns:DiscordianResponse" />
  </wsdl:message>
  <wsdl:portType name="ServiceSoap">
    <wsdl:operation name="Discordian">
      <wsdl:input message="tns:DiscordianSoapIn" />
      <wsdl:output message="tns:DiscordianSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="Discordian">
      <soap:operation soapAction="http://reboltutorial.com/Discordian" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="Discordian">
      <soap12:operation soapAction="http://reboltutorial.com/Discordian" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="Service">
    <wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
      <soap:address location="http://reboltutorial.com/cgi-bin/discordian.cgi" />
    </wsdl:port>
    <wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
      <soap12:address location="http://reboltutorial.com/cgi-bin/discordian.cgi" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

推荐答案

我写了那个代码 http://www.rebolforces.com/zine/rzine-1-02/#sect6.9 年前,从那时起就没有真正做过多少 SOAP.

I wrote that code http://www.rebolforces.com/zine/rzine-1-02/#sect6. 9 years ago and haven't really done much SOAP since then.

它在 http://www.soapclient.com/soaptest.html

当时我手动修改了 wdsl ... 想试试我的吗?

At that time I hand modified the wdsl ... wanna try mine?

这篇关于Webservice 可与 SoapSonar 一起使用,但不能与 Visual Studio Winform 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆