【发布时间】:2012-02-20 16:10:23
【问题描述】:
我需要创建一个服务供客户使用/消费(我认为消费是正确的术语)。
我是WCF 和web services 的新手。
我已经完成了大部分教程,并且对一切的工作原理有所了解。
现在我有了这个 wsdl 文件:
<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://196.37.139.18/IntegrationTest/ShopriteIntegrationService"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://196.37.139.18/IntegrationTest/ShopriteIntegrationService">
<wsdl:types>
<s:schema elementFormDefault="qualified"
targetNamespace="http://196.37.139.18/IntegrationTest/ShopriteIntegrationService">
<s:element name="ChangePassword">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="serviceProviderGuid" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="oldPassword" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="newPassword" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ChangePasswordResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ChangePasswordResult">
<s:complexType mixed="true">
<s:sequence>
<s:any/>
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetCampaignSchedulePlacements">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="serviceProviderGuid" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetCampaignSchedulePlacementsResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetCampaignSchedulePlacementsResult">
<s:complexType mixed="true">
<s:sequence>
<s:any/>
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ConfirmDownload">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="serviceProviderGuid" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="dateOfLatestRecordRecieved" type="s:dateTime"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ConfirmDownloadResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ConfirmDownloadResult">
<s:complexType mixed="true">
<s:sequence>
<s:any/>
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="UploadCampaignSchedulePlacements">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="serviceProviderGuid" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="xml" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="UploadCampaignSchedulePlacementsResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="UploadCampaignSchedulePlacementsResult">
<s:complexType mixed="true">
<s:sequence>
<s:any/>
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="ChangePasswordSoapIn">
<wsdl:part name="parameters" element="tns:ChangePassword"/>
</wsdl:message>
<wsdl:message name="ChangePasswordSoapOut">
<wsdl:part name="parameters" element="tns:ChangePasswordResponse"/>
</wsdl:message>
<wsdl:message name="GetCampaignSchedulePlacementsSoapIn">
<wsdl:part name="parameters" element="tns:GetCampaignSchedulePlacements"/>
</wsdl:message>
<wsdl:message name="GetCampaignSchedulePlacementsSoapOut">
<wsdl:part name="parameters" element="tns:GetCampaignSchedulePlacementsResponse"/>
</wsdl:message>
<wsdl:message name="ConfirmDownloadSoapIn">
<wsdl:part name="parameters" element="tns:ConfirmDownload"/>
</wsdl:message>
<wsdl:message name="ConfirmDownloadSoapOut">
<wsdl:part name="parameters" element="tns:ConfirmDownloadResponse"/>
</wsdl:message>
<wsdl:message name="UploadCampaignSchedulePlacementsSoapIn">
<wsdl:part name="parameters" element="tns:UploadCampaignSchedulePlacements"/>
</wsdl:message>
<wsdl:message name="UploadCampaignSchedulePlacementsSoapOut">
<wsdl:part name="parameters" element="tns:UploadCampaignSchedulePlacementsResponse"/>
</wsdl:message>
<wsdl:portType name="ShopriteIntegrationTestoap">
<wsdl:operation name="ChangePassword">
<wsdl:input message="tns:ChangePasswordSoapIn"/>
<wsdl:output message="tns:ChangePasswordSoapOut"/>
</wsdl:operation>
<wsdl:operation name="GetCampaignSchedulePlacements">
<wsdl:input message="tns:GetCampaignSchedulePlacementsSoapIn"/>
<wsdl:output message="tns:GetCampaignSchedulePlacementsSoapOut"/>
</wsdl:operation>
<wsdl:operation name="ConfirmDownload">
<wsdl:input message="tns:ConfirmDownloadSoapIn"/>
<wsdl:output message="tns:ConfirmDownloadSoapOut"/>
</wsdl:operation>
<wsdl:operation name="UploadCampaignSchedulePlacements">
<wsdl:input message="tns:UploadCampaignSchedulePlacementsSoapIn"/>
<wsdl:output message="tns:UploadCampaignSchedulePlacementsSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ShopriteIntegrationTestoap" type="tns:ShopriteIntegrationTestoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="ChangePassword">
<soap:operation soapAction="http://196.37.139.18/IntegrationTest/ShopriteIntegrationService/ChangePassword" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetCampaignSchedulePlacements">
<soap:operation soapAction="http://196.37.139.18/IntegrationTest/ShopriteIntegrationService/GetCampaignSchedulePlacements" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="ConfirmDownload">
<soap:operation soapAction="http://196.37.139.18/IntegrationTest/ShopriteIntegrationService/ConfirmDownload" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="UploadCampaignSchedulePlacements">
<soap:operation soapAction="http://196.37.139.18/IntegrationTest/ShopriteIntegrationService/UploadCampaignSchedulePlacements" 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="ShopriteIntegrationServiceSoap12" type="tns:ShopriteIntegrationServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="ChangePassword">
<soap12:operation soapAction="http://196.37.139.18/IntegrationTest/ShopriteIntegrationService/ChangePassword" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetCampaignSchedulePlacements">
<soap12:operation soapAction="http://196.37.139.18/IntegrationTest/ShopriteIntegrationService/GetCampaignSchedulePlacements" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="ConfirmDownload">
<soap12:operation soapAction="http://196.37.139.18/IntegrationTest/ShopriteIntegrationService/ConfirmDownload" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="UploadCampaignSchedulePlacements">
<soap12:operation soapAction="http://196.37.139.18/IntegrationTest/ShopriteIntegrationService/UploadCampaignSchedulePlacements" 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="ShopriteIntegrationService">
<wsdl:port name="ShopriteIntegrationServiceSoap" binding="tns:ShopriteIntegrationTestoap">
<soap:address location="http://jhbweb01/IntegrationTest/ShopriteIntegrationService.asmx"/>
</wsdl:port>
<wsdl:port name="ShopriteIntegrationServiceSoap12" binding="tns:ShopriteIntegrationServiceSoap12">
<soap12:address location="http://jhbweb01/IntegrationTest/ShopriteIntegrationService.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
这就是我得到的:
[ServiceContract]
public interface IShopriteService
{
[OperationContract]
void ChangePassword(string serviceProviderGuid, string oldPassword, DateTime newPassword);
[OperationContract]
string ChangePasswordResponse();
[OperationContract]
void GetCampaignSchedulePlacements(string serviceProviderGuid, string password);
[OperationContract]
string GetCampaignSchedulePlacementsResponse();
[OperationContract]
void ConfirmDownload(string serviceProviderGuid, string password, DateTime dateOfLatestRecordRecieved);
[OperationContract]
string ConfirmDownloadResponse();
[OperationContract]
void UploadCampaignSchedulePlacements(string serviceProviderGuid, string password, string xml);
[OperationContract]
string UploadCampaignSchedulePlacementsResponse();
}
实现的方法:
public class ShopriteService : IShopriteService
{
public void ChangePassword(string serviceProviderGuid, string oldPassword, DateTime newPassword)
{
throw new NotImplementedException();
}
public string ChangePasswordResponse()
{
throw new NotImplementedException();
}
public void GetCampaignSchedulePlacements(string serviceProviderGuid, string password)
{
throw new NotImplementedException();
}
public string GetCampaignSchedulePlacementsResponse()
{
throw new NotImplementedException();
}
public void ConfirmDownload(string serviceProviderGuid, string password, DateTime dateOfLatestRecordRecieved)
{
throw new NotImplementedException();
}
public string ConfirmDownloadResponse()
{
throw new NotImplementedException();
}
public void UploadCampaignSchedulePlacements(string serviceProviderGuid, string password, string xml)
{
throw new NotImplementedException();
}
public string UploadCampaignSchedulePlacementsResponse()
{
throw new NotImplementedException();
}
}
我什至不知道我是否走在正确的轨道上......
解释一下,wsdl 文件中发生了什么。
从这里到哪里去?
我可以使用某种结构吗? (如MVVM 结构)
【问题讨论】:
-
我从这里去哪里是什么意思?你想达到什么目标?
-
@Rajesh 我需要创建一个服务供客户使用/消费(我认为消费是正确的术语)。
-
看起来您已经实现了 wsdl 中定义的服务,而不是使用它的客户端。
-
@BenRobinson Ben,那我该怎么办?那我就完全走错了路……
-
看起来不错,开始填写方法实现。
标签: c# wcf web-services wsdl