我對web服務完全陌生,所以請原諒,如果這對每個人都是顯而易見的,但除了我自己。WCF Web服務方式名稱
我創建了一個運行良好的WCF C#web服務。然後我創建了Java和一個C#客戶端來消費輸出,這也很好。
什麼困擾我是我無法弄清楚如何控制在代理中創建的方法的名稱。在服務中,我有一個名爲getCategory的方法,但是在生成的客戶端代碼中(使用Netbeans的Java中以及使用VS的C#中),相應的方法被命名爲getX003CCategoryX003EKBackingField()。
可以控制這個名字嗎?
編輯: 這裏是從服務剪斷:
[OperationContract(Name="GetCategoryObject")]
UrlCategory2 GetCategoryObject(string URL);
,合同:
[DataMember(Name="getCategory")]
public string Category {
get;
set;
}
我生成使用WSDL代碼閱讀在Eclipse和Visual Studio自動化。
SECOND EDIT:這應該有所有的相關位。
namespace MyService.ServiceContracts
{
[ServiceContract(Name = "ICategorizer", Namespace = "MyService.ServiceContracts", SessionMode = SessionMode.Allowed)]
public interface ICategorizer
{
[OperationContract(Name="GetCategoryObject")]
UrlCategory2 GetCategoryObject(string URL);
[OperationContract]
string getCategoryAsString(string URL);
}
}
namespace MyService.DataContracts {
[Serializable]
public class UrlCategory2 {
[DataMember(Name = "getCategoryEn")]
public string CategoryEn {
get;
set;
}
[DataMember(Name = "getCategoryFr")]
public string PawsCategoryFr {
get;
set;
}
[DataMember(Name="getCategory")]
public string Category {
get;
set;
}
}
}
namespace MyService
{
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerSession, UseSynchronizationContext = false)]
public class MyService : ICategorizer
{
...
public UrlCategory2 GetCategory(string URL) {...}
...
public UrlCategory2 GetCategoryObject(string URL) {...}
}
}
[wsdl:operation name="GetCategoryObject"]
[soap:operation soapAction="MyService.ServiceContracts/ICategorizer/GetCategoryObject" style="document"/]
[wsdl:input]
[soap:body use="literal"/]
[/wsdl:input]
[wsdl:output]
[soap:body use="literal"/]
[/wsdl:output]
[/wsdl:operation]
[wsdl:operation name="GetCategory"]
[soap:operation soapAction="MyService.ServiceContracts/ICategorizer/GetCategory" style="document"/]
[wsdl:input]
[soap:body use="literal"/]
[/wsdl:input]
能取悅你張貼服務的WSDL,如果它是不是太大?如果它太大,至少GetCategoryObject操作的「wsdl:operation」元素。 – 2011-05-17 17:44:41
對於格式化混亂的抱歉 - 我的第一篇文章,我仍然試圖找出標記 – Javawanabe 2011-05-17 19:30:12
代碼塊每行開始四個空格。最簡單的方法是標記代碼,然後按下「{}」按鈕(我冒昧地爲您做)。 – 2011-05-17 19:42:53