【发布时间】:2013-04-19 06:27:33
【问题描述】:
我创建了一个web-service客户端,编译了一个WSDL,除了调用Logon方法后的空属性(ResponseCode等都是空的),一切正常。
我有一个响应 SOAP 消息:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sas="http://ws.test.com/">
<soapenv:Header/>
<soapenv:Body>
<sas:LogonResponse>
<SessionID>19790</SessionID>
<ResponseCode>0</ResponseCode>
<ResponseMessage>Logon OK</ResponseMessage>
</sas:LogonResponse>
</soapenv:Body>
</soapenv:Envelope>
此方法的 WSDL 部分如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:sas="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://ws.test.com/" xmlns:ns="http://ws.test.com/" targetNamespace="http://ws.test.com/">
<wsdl:types>
<sas:schema xmlns:sas="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ws.test.com/" elementFormDefault="qualified">
<sas:element name="Logon">
<sas:complexType>
<sas:sequence>
<sas:element name="Username" type="sas:string" nillable="false"/>
<sas:element name="Password" type="sas:string" nillable="false"/>
</sas:sequence>
</sas:complexType>
</sas:element>
<sas:element name="LogonResponse">
<sas:complexType>
<sas:sequence>
<sas:element name="SessionID" type="sas:long" nillable="false"/>
<sas:element name="ResponseCode" type="sas:integer" nillable="false"/>
<sas:element name="ResponseMessage" type="sas:string" nillable="false"/>
</sas:sequence>
</sas:complexType>
</sas:element>
</sas:schema>
</wsdl:types>
<wsdl:message name="LogonRequest">
<wsdl:part name="Logon" element="tns:Logon"/>
</wsdl:message>
<wsdl:message name="LogonResponse">
<wsdl:part name="LogonResponse" element="tns:LogonResponse"/>
</wsdl:message>
<wsdl:portType name="rrrwebservice">
<wsdl:operation name="Logon">
<wsdl:input message="tns:LogonRequest"/>
<wsdl:output message="tns:LogonResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="mvcBinding" type="tns:rrrwebservice">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Logon">
<soap:operation
soapAction="http://ws.test.com/Logon" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="RRRWebService">
<wsdl:port name="RRRWebService" binding="tns:mvcBinding">
<soap:address location="http://172.6.2.14:8008/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
无法找出问题所在。 我通过在 Visual Studio 2008 中选择“添加服务引用”来编译它。 任何 cmets 和答案将不胜感激! 谢谢。
【问题讨论】:
-
我已经编辑了你的标题。请参阅“Should questions include “tags” in their titles?”,其中的共识是“不,他们不应该”。
-
抱歉,编辑了帖子并更正了 ws.test.com 命名空间。出于安全原因,它是手动更改的
-
究竟哪一个是错的?
-
要么。它们必须相同。
-
两者都是“ws.test.com”不是吗?
标签: c# wcf web-services wsdl