我有以下应用程序配置文件,使用我的 ip 作为基本地址:
<?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 服务的字符串表示形式。从 http://{IP-ADDRESS}:{PORT}/?singleWsdl 获取。但它似乎不起作用,我不知道为什么。我总是得到错误:
Run-time error '-2147221020 (800401e4)':
Automation error
Invalid syntax