我使用my ip作为baseAddress获得以下app配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="HelloServiceExample.HelloService" behaviorConfiguration="mexBehavior">
<endpoint
address="HelloService"
binding="basicHttpBinding"
contract="HelloServiceExample.IHelloService">
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://{IP-ADDRESS}:{PORT}/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
我在VBA中编写了一个相应的基于wsdl的名字对象字符串:
wsdlMonikerString = _
"service4:address='http://{IP-ADDRESS}:{PORT}/HelloService.svc' " & _
", binding=BasicHttpBinding_IHelloService" & _
", bindingNamespace='http://tempuri.org/'" & _
", wsdl='" & wsdlText & "'" & _
", contract=IHelloService" & _
", contractNamespace='http://tempuri.org/'"
其中wsdlText是wsdl服务的字符串respresentation。来自http:// {IP-ADDRESS}:{PORT} /?singleWsdl。但它似乎不起作用,我无法弄清楚原因。我总是得到错误:
Run-time error '-2147221020 (800401e4)':
Automation error
Invalid syntax