将响应格式更改为VS,错误现在是“无法识别消息版本”
<?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
实现是一个cgi而不是.net框架程序,但这并不重要,因为它是webservices的目的。
我使用SoapSonar成功测试了它:
http://reboltutorial.com/images/soapsonar.png
但是在Visual Studio下,它失败了这段代码:
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);
}
你能看到什么原因吗?感谢。
请求如下:
<?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(如果需要):
<?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>
答案 0 :(得分:0)
我写了代码http://www.rebolforces.com/zine/rzine-1-02/#sect6。 9年前,从那时起就没有真正做过多的SOAP。
它适用于http://www.soapclient.com/soaptest.html
的Soapclient当时我手动修改了wdsl ...想尝试一下吗?