2011-06-13 36 views
0

我無法繞過調用第三方服務的簡單方法。這裏的WSDL的此方法的塊:如何調用這個webservice方法?

<s:element name="PushRequest"> 
    <s:complexType> 
     <s:sequence> 
      <s:element minOccurs="0" maxOccurs="1" name="LocationCode" type="s:string"/> 
      <s:element minOccurs="0" maxOccurs="1" name="PushRequestXml" type="s:string"/> 
      <s:element minOccurs="0" maxOccurs="1" name="PassPhrase" type="s:string"/> 
     </s:sequence> 
    </s:complexType> 
</s:element> 

這是一個示例SOAP 1.1請求,由網絡服務生成:

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <PushRequest xmlns="http://xxxx.yyyy.com/"> 
     <LocationCode>string</LocationCode> 
     <PushRequestXml>string</PushRequestXml> 
     <PassPhrase>string</PassPhrase> 
    </PushRequest> 
    </soap:Body> 
</soap:Envelope> 

首先,我認爲,這是複雜的類型的一個參數,所以我試過這個:

ws = CreateObject("webservice", serviceURL); 

push = {}; 
push["LocationCode"] = "xxx"; 
push["PushRequestXml"] = "yyy"; 
push["PassPhrase"] = "zzz"; 

responseXML = ws.PushRequest(push); 

但是得到了通常的CF響應Web service operation PushRequest with parameters {{PushRequestXml={yyy},LocationCode={xxx},PassPhrase={zzz}}} cannot be found.

接下來我想,也許這不是一個複雜的論證(至少它沒有一個XML格式的name屬性),但三個不同的參數:

ws = CreateObject("webservice", serviceURL); 

responseXML = ws.PushRequest(LocationCode = "xxx", PushRequestXml = "yyy", PassPhrase = "zzz"); 

結果是一樣的:Web service operation PushRequest with parameters {PushRequestXml={{PushRequestXml, yyy}},LocationCode={{LocationCode, xxx}},PassPhrase={{PassPhrase, zzz}}} cannot be found.

任何想法如何處理?請告知是否需要更多信息。

我使用ACF9,webservice由ASP.net提供

謝謝。

+0

你試過使用CFBuilder,並將serviceURL粘貼到服務瀏覽器(Show Web Services - > +)中,然後右鍵單擊它以生成正確的createObject()調用? – Henry 2011-06-13 18:12:35

+0

只是猜測,但可能的元素,即'LocationCode,PushRequestXml,..'是數組? @亨利 - 我不使用CFB,但這聽起來很酷! – Leigh 2011-06-13 18:17:30

+0

@亨利感謝您的提示,我沒有CFB(和Windows),但我想我會找到一種方法。 – Sergii 2011-06-13 18:27:03

回答

2

我已經結束了在web服務中使用普通POST POST原始XML並手動解析響應XML,如this blog post中提議的那樣。

而且我已經試過的WSDL2Java在該博客系列的第三部分提出,但它並沒有幫助我 - 方法完全相同看起來先前預期:

public java.lang.String pushRequest(java.lang.String locationCode, java.lang.String pushRequestXml, java.lang.String passPhrase) throws java.rmi.RemoteException; 

其結果是,我沒有找到適用於我的web服務的cfinvoke的方法。

所以,我的當前請求的代碼如下所示:

<cfsavecontent variable="SOAPXML"> 
<cfoutput> 
<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <PushRequest xmlns="http://serviceurl.com/"> 
     <LocationCode>#LocationCode#</LocationCode> 
     <PushRequestXml>#XMLFormat(Trim(PushRequestXml))#</PushRequestXml> 
     <PassPhrase>#PassPhrase#</PassPhrase> 
    </PushRequest> 
    </soap:Body> 
</soap:Envelope> 
</cfoutput> 
</cfsavecontent> 

<cfhttp method="post" url="#ServiceURL#"> 
    <cfhttpparam type="header" name="SOAPAction" value="http://serviceurl.com/PushRequest" /> 
    <cfhttpparam type="xml" value="#Trim(SOAPXML)#" /> 
</cfhttp> 

服務返回XML,所以在處理這不是一個問題。

+0

由於它很容易重現,我認爲最好向Adobe報告這個錯誤? http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html – Henry 2011-06-14 17:16:05

+0

@亨利我真的不知道如何描述這個問題,再加上我還不確定這不是我的錯誤。 – Sergii 2011-06-14 21:36:04

+0

根據你發佈的內容,*似乎*就像一個基本的結構應該工作。任何機會有這個Web服務的公共wsdl? – Leigh 2011-06-14 22:29:51

0

您是否嘗試過使用CFBuilder,並將serviceURL粘貼到服務瀏覽器(顯示Web服務 - > +)中,然後右鍵單擊以生成正確的createObject()調用?

Services Browser in CFBuilder 2

+0

謝謝,但正如我在評論中所說的那樣,瀏覽器給了我完全相同的代碼,我已經在使用cfinvoke和createobject。 – Sergii 2011-06-14 09:33:34

0

我在WSDL沒有大師,但我似乎記得,自動生成WSDL的通常是「請求」或「響應」後綴的方法,所以你可能需要將其簡稱爲「推」而不是「PushRequest」。

ws = CreateObject("webservice", serviceURL); 

push = {}; 
push["LocationCode"] = "xxx"; 
push["PushRequestXml"] = "yyy"; 
push["PassPhrase"] = "zzz"; 

responseXML = ws.Push(push); 

值得一試。

+0

不,它也行不通。另外,提供的示例明確指出方法名稱爲「PushRequest」。感謝您的嘗試,任何方式。 – Sergii 2011-06-14 08:55:18