2009-12-23 52 views
3

更新:Problem solved這種Web服務方法有什麼問題?


我要調用的web服務方法(dduLogin),它返回3個參數。我通過Visual Studio通過「添加Web引用」生成了代碼。這是WSDL的相關部分:

<message name="dduLoginRequest"> 
    <part name="Ticket" type="xsd:string"/> 
    <part name="ServiceId" type="xsd:string"/> 
    <part name="Market" type="xsd:string"/> 
    <part name="Application" type="xsd:string"/> 
    <part name="Brand" type="xsd:string"/> 
    <part name="Sincom" type="xsd:string"/> 
    <part name="CertificationSystem" type="xsd:string"/> 
</message> 


<message name="dduLoginResponse"> 
    <part name="Ticket" type="xsd:string"/> 
    <part name="LoginId" type="xsd:string"/> 
    <part name="Return" type="xsd:string"/> 
</message> 
<portType name="dduPortType"> 
    <operation name="dduLogin"> 
     <input message="tns:dduLoginRequest"/> 
     <output message="tns:dduLoginResponse"/> 
    </operation> 


</portType> 
<binding name="dduBinding" type="tns:dduPortType"> 
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <operation name="dduLogin"> 
     <soap:operation soapAction="urn:ddu#dduLogin" style="rpc"/> 
     <input> 
      <soap:body use="encoded" namespace="urn:ddu" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
     </input> 
     <output> 
      <soap:body use="encoded" namespace="urn:ddu" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
     </output> 
    </operation> 


</binding> 

它可以調用這個方法,這是返回的XML:

<SOAP-ENV:Body><ns1:dduLoginResponse xmlns:ns1="urn:ddu"> 
    <Ticket xsi:type="xsd:string">M-S%40%2AT6%2F%26179G%23%24%25%25%2A%40%40LDNT%27BP%3F9C%2CRY9-Z8C0C%3D0JXD%24_%2A%5EFKF%26DV%3BIP_8%3DM.E3VBDU7%3CAB%5C9_%22%3A%29E9%2CYO6%5C8I%5D6J%5EZ%60%2C8%3A%26%60%25U%3B.6A4G%2BO%5EQA%5DINI4X2%247%29M%2C%3B%3DZ%5CQ%3C%3A%27%3AB%5CSUB%3F9GAPC%3DRV%3CA%5E%2CE7%40L3%3F%3FY%215T%27%40B%3FKUJIH%3D%2B150Q%3CD%3A%3B%21D%22%3B%3ED%60%60%0A</Ticket> 
    <LoginId xsi:type="xsd:string">22459</LoginId> 
    <Return xsi:type="xsd:string">0</Return></ns1:dduLoginResponse> 
</SOAP-ENV:Body> 

但通話結束後,並非所有的返回值儘可能填充。這是由Visual Studio生成該方法的代碼:

[System.Web.Services.Protocols.SoapRpcMethodAttribute("urn:ddu#dduLogin", RequestNamespace="urn:ddu", ResponseNamespace="urn:ddu")] 
[return: System.Xml.Serialization.SoapElementAttribute("LoginId")] 
public string dduLogin(ref string Ticket, string ServiceId, string Market, string Application, string Brand, string Sincom, string CertificationSystem, out string Return) { 
    object[] results = this.Invoke("dduLogin", new object[] { 
     Ticket, 
     ServiceId, 
     Market, 
     Application, 
     Brand, 
     Sincom, 
     CertificationSystem}); 
    Ticket = ((string)(results[1])); 
    Return = ((string)(results[2])); 
    return ((string)(results[0])); 
} 

這就像結果是錯誤的順序(門票應該是results[0]),並登錄ID應該是results[1]results[1]也爲空(NULL)。

這裏有什麼問題?我錯過了什麼嗎?這是一個糟糕的WSDL?它是Visual Studio Web服務代理生成器嗎?有人有過這個?有關如何解決這個問題的任何建議?

順便說一句,同事可以使用另一個Web服務工具集(完全不與.NET相關)成功地調用此Web服務。

編輯:這裏是來自Wsdl.exe用輸出有問題的WSDL:

C:\temp>wsdl https://eu.link.fiatauto.com/tsi/DDUWsAut.php?wsdl 
Microsoft (R) Web Services Description Language Utility 
[Microsoft (R) .NET Framework, Version 2.0.50727.3038] 
Copyright (C) Microsoft Corporation. All rights reserved. 
Warning: This web reference does not conform to WS-I Basic Profile v1.1. 
R2706: A wsdl:binding in a DESCRIPTION MUST use the value of "literal" for the u 
se attribute in all soapbind:body, soapbind:fault, soapbind:header and soapbind: 
headerfault elements. 
    - Input element soapbind:body of operation 'dduLogin' on portType 'dduBinding 
' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduLogin' on portType 'dduBindin 
g' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduLogout' on portType 'dduBindin 
g' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduLogout' on portType 'dduBindi 
ng' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduDir' on portType 'dduBinding' 
from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduDir' on portType 'dduBinding' 
from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduGetGroupList' on portType 'ddu 
Binding' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduGetGroupList' on portType 'dd 
uBinding' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduGetGroupFileList' on portType 
'dduBinding' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduGetGroupFileList' on portType 
'dduBinding' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduCreate' on portType 'dduBindin 
g' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduCreate' on portType 'dduBindi 
ng' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduOpen' on portType 'dduBinding' 
from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduOpen' on portType 'dduBinding 
' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduClose' on portType 'dduBinding 
' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduClose' on portType 'dduBindin 
g' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduAbort' on portType 'dduBinding 
' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduAbort' on portType 'dduBindin 
g' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduRead' on portType 'dduBinding' 
from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduRead' on portType 'dduBinding 
' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduWrite' on portType 'dduBinding 
' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduWrite' on portType 'dduBindin 
g' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduGet' on portType 'dduBinding' 
from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduGet' on portType 'dduBinding' 
from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduPost' on portType 'dduBinding' 
from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduPost' on portType 'dduBinding 
' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduGetAtt' on portType 'dduBindin 
g' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduGetAtt' on portType 'dduBindi 
ng' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduPostAtt' on portType 'dduBindi 
ng' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduPostAtt' on portType 'dduBind 
ing' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduTransaction' on portType 'dduB 
inding' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduTransaction' on portType 'ddu 
Binding' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduCommit' on portType 'dduBindin 
g' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduCommit' on portType 'dduBindi 
ng' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduRollback' on portType 'dduBind 
ing' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduRollback' on portType 'dduBin 
ding' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduLoginDescr' on portType 'dduBi 
nding' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduLoginDescr' on portType 'dduB 
inding' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduIsRemoteDebug' on portType 'dd 
uBinding' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduIsRemoteDebug' on portType 'd 
duBinding' from namespace 'urn:ddu'. 
    - Input element soapbind:body of operation 'dduLogClient' on portType 'dduBin 
ding' from namespace 'urn:ddu'. 
    - Output element soapbind:body of operation 'dduLogClient' on portType 'dduBi 
nding' from namespace 'urn:ddu'. 

For more details on the WS-I Basic Profile v1.1, see the specification 
at http://www.ws-i.org/Profiles/BasicProfile-1.1.html. 

Writing file 'C:\temp\ddu.cs'. 

更新

我已經按照@Benjamin's建議,並使用WCF創建一個客戶端。我確實有一些問題:wsdl包含一些不應該有空格的空格,並且服務的編碼顯然是ISO-8859-1,所以我最終創建了自己的CustomTextMessageEncoder

由於我期待着使用這個服務的道路上出現更多的問題,我仍然非常希望得到這個與舊式Web服務引用一起工作,所以如果任何人有另一個線索爲什麼沒有解析返回的XML沒錯,這裏是URL到WSDL:

https://eu.link.fiatauto.com/tsi/DDUWsAut.php?wsdl

請注意,移除的空間(這是試圖在服務引用方式,我所遇到的問題)沒有解決這個問題( wsdl.exe的輸出仍然是th同樣沒有空格)。

回答

1

我提出與服務提供商的問題,頗有些後故障排除(他們沒能第一重現),它有明顯的相同服務2個不同的端點變得清晰:

我用它默認的一個:

https://eu.link.fiatauto.com/tsi/DDUWsAut.php

和他們使用另一個(顯然specificall Y代表DOTNET客戶端):

https://eu.link.fiatauto.com/tsi/DDUWsAutDotNet.php

爲什麼會需要仍然是我也不清楚,但在另一種代替使用DOTNET特定端點解決我的問題,所以我問沒有更多的問題。

+0

這是必需的,因爲它們的服務不符合WS-I BP 1. RPC /編碼(它們使用的樣式)會產生模糊的消息,因此不應使用。 – 2010-01-22 18:36:31

1

我有類似的問題,他們消失了,當我使用WCF(即:添加服務引用而不是Web引用的)來生成代理類。

+0

我想不依賴於.NET 3.5,但如果沒有其他方法,我會研究這一點。 – fretje 2009-12-23 15:09:34

+0

我看着它,但有問題。請參閱http://stackoverflow.com/questions/1954805/how-can-i-make-wcf-talk-to-this-web-service。 – fretje 2009-12-23 19:23:08

1

您可以嘗試使用wsdl.exe工具創建代理類文件,而不是使用「添加引用」。如果您使用代理類具有相同的缺少返回值問題,則可嘗試手動編輯代理類文件以解決您的問題。

Wsdl.exe用 http://msdn.microsoft.com/en-us/library/7h3ystb6%28VS.80%29.aspx

您的問題可能是類似於此的博客文章中描述的問題。 http://blogs.msdn.com/eugeneos/archive/2007/02/05/solving-the-disappearing-data-issue-when-using-add-web-reference-or-wsdl-exe-with-wcf-services.aspx

+0

其中一個結果爲空(空),而它應該包含一個值。這不是手工編輯生成的代理類所能解決的問題。 – fretje 2009-12-23 16:35:51

+0

我試過wsdl.exe。添加輸出到問題。 – fretje 2009-12-23 19:18:51