2012-05-04 32 views
1

我一直在試圖實施以前貼在下面的問題提供exmaples服務:調用WCF(.SVC)從VBScript,WScript的,VBA等與參數

Calling WCF service by VBScript

在我的具體情況我需要傳入一個字符串變量,它將返回一串字符串,但運氣不大。

我懷疑我在收到正確的信封請求時遇到困難。下面是我試圖打電話給的wdsl。你能給我一個例子,我可以如何調用這個傳遞參數並解析返回數組?

<?xml version="1.0" encoding="utf-8" ?> 
<wsdl:definitions name="TestSvc" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"> 
<wsdl:types> 
<xsd:schema targetNamespace="http://tempuri.org/Imports"> 
    <xsd:import schemaLocation="http://localHost/testSvc.svc?xsd=xsd0" namespace="http://tempuri.org/" /> 
    <xsd:import schemaLocation="http://localHost/testSvc.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" /> 
    <xsd:import schemaLocation="http://localHost/testSvc.svc?xsd=xsd2" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" /> 
    </xsd:schema> 
    </wsdl:types> 
<wsdl:message name="ITestSvc_GetDataBy_Id_InputMessage"> 
<wsdl:part name="parameters" element="tns:GetDataBy_Id" /> 
</wsdl:message> 
<wsdl:message name="ITestSvc_GetDataBy_Id_OutputMessage"> 
    <wsdl:part name="parameters" element="tns:GetDataBy_IdResponse" /> 
    </wsdl:message> 
<wsdl:portType name="ITestSvc"> 
<wsdl:operation name="GetDataBy_Id"> 
    <wsdl:input wsaw:Action="http://tempuri.org/ITestSvc/GetDataBy_Id" message="tns:ITestSvc_GetDataBy_Id_InputMessage" /> 
    <wsdl:output wsaw:Action="http://tempuri.org/ITestSvc/GetDataBy_IdResponse" message="tns:ITestSvc_GetDataBy_Id_OutputMessage" /> 
    </wsdl:operation> 
<wsdl:binding name="BasicHttpBinding_TestSvc" type="tns:ITestSvc"> 
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
<wsdl:operation name="GetDataBy_Id"> 
    <soap:operation soapAction="http://tempuri.org/ITestSvc/GetDataBy_Id" style="document" /> 
<wsdl:input> 
    <soap:body use="literal" /> 
    </wsdl:input> 
<wsdl:output> 
    <soap:body use="literal" /> 
    </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
<wsdl:service name="TestSvc"> 
<wsdl:port name="BasicHttpBinding_ITestSvc" binding="tns:BasicHttpBinding_ITestSvc"> 
    <soap:address location="http://localhost/TestSvc.svc" /> 
    </wsdl:port> 
    </wsdl:service> 
    </wsdl:definitions> 

回答

1

這WSDL文檔不包含該操作的輸入/輸出模式(所有<wsdl:import>語句),所以這是不可能告訴請求應該是什麼樣子僅根據這一信息。

但您可以做的一件事是:打開WCFTestClient.exe,將其指向正在運行的服務的WSDL,然後 - ,同時運行諸如Fiddler的工具 - 向服務發送請求。這樣你就可以看到請求和服務響應。此時,複製請求(包括諸如HTTP標頭SOAPAction,如果適用的話)和請求主體。