Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 使用VS 2010使用第三方web服务_.net_Vb.net_Web Services - Fatal编程技术网

.net 使用VS 2010使用第三方web服务

.net 使用VS 2010使用第三方web服务,.net,vb.net,web-services,.net,Vb.net,Web Services,我需要从COTS应用程序中使用JavaWeb服务。我只得到wsdl来使用它。它要求我提供用户名和密码。我以前在.NET2005Windows服务中使用WSE3.0使用它们。我正在尝试将windows服务升级到2010 我通过Add服务添加了对服务的引用。(由于公司的政策,我不得不更改自定义名称和服务器,希望我没有产生语法错误。)我不得不编辑链接,因为这是我的第一篇文章 我看到它在我的应用程序配置中添加了条目: <startup><supportedRuntime version

我需要从COTS应用程序中使用JavaWeb服务。我只得到wsdl来使用它。它要求我提供用户名和密码。我以前在.NET2005Windows服务中使用WSE3.0使用它们。我正在尝试将windows服务升级到2010

我通过Add服务添加了对服务的引用。(由于公司的政策,我不得不更改自定义名称和服务器,希望我没有产生语法错误。)我不得不编辑链接,因为这是我的第一篇文章

我看到它在我的应用程序配置中添加了条目:

<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup><system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="MyServiceSoapBinding">
                <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                    messageVersion="Soap12" writeEncoding="utf-8">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                </textMessageEncoding>
                <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                    maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
                    bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
                    keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
                    realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                    useDefaultWebProxy="true" />
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="htp://servername:1234/webservices/thewebservicename"
            binding="customBinding" bindingConfiguration="MyServiceSoapBinding"
            contract="MyServiceReference.thewebservicename" name="thewebservicenameSoapPort" />
    </client>
</system.serviceModel>
我收到以下错误:{“BasicHttp绑定要求BasicHttpBinding.Security.Message.ClientCredentialType与安全消息的BasicHttpMessageCredentialType.Certificate凭据类型等效。选择Transport或TransportWithMessageCredential Security作为用户名凭据。“} System.InvalidOperationException:{“BasicHttp绑定要求BasicHttpBinding.Security.Message.ClientCredentialType与安全消息的BasicHttpMessageCredentialType.Certificate凭据类型等效。为用户名凭据选择Transport或TransportWithMessageCredential Security。”}

更改安全模式只会导致不同的错误(需要Soap头;需要https而不是http…)

经过研究,我发现我需要使用WSHttpBinding。我更改了绑定并得到错误:{“响应消息的内容类型text/xml;charset=utf-8与绑定的内容类型不匹配(multipart/related;type=“application/xop+xml”)。如果使用自定义编码器,请确保正确实现了IsContentTypeSupported方法。响应的前373个字节为:“env:VersionMismatch无法在命名空间中找到信封。根元素为”htp://www.w3.org/2003/05/soap-envelope命名空间“信封”中的“。”} System.ServiceModel.ProtocolException:{“响应消息的内容类型text/xml;charset=utf-8与绑定的内容类型不匹配(multipart/related;type=“application/xop+xml”)。如果使用自定义编码器,请确保正确实现了IsContentTypeSupported方法。响应的前373个字节为:“env:VersionMismatch无法在命名空间中找到信封。”htp://schemas.xmlsoap.org/soap/envelope/. 根元素是“htp://www.w3.org/2003/05/soap-envelope命名空间“信封”中的“。”}

我做了更多的研究,将app.config中的messageVersion=“Soap12”更改为messageVersion=“Soap11”,得到了相同的错误。我将WSMessageEncoding更改为文本,并得到一条类似的错误消息(绑定为application/soap+xml)。我在这方面所能找到的所有研究似乎都在使用WCF服务,而不是java

任何帮助都将不胜感激! 贝卡

    Dim Binding As BasicHttpBinding
    Dim Binding As CustomBinding
    Dim EndPoint As EndpointAddress
    Dim etFramework As MyServiceReference.thewebserviceClient
    Dim rsp As MyServiceReference.MethodResponse
    Dim req As MyServiceReference.atkinpovoucherRequest
    Dim rsp1 As MyServiceReference.atkinpovoucherResponse


        Binding = New BasicHttpBinding()
        Binding.Name = "MyServiceSoapBinding"
        Binding.Security.Mode = BasicHttpSecurityMode.Message
        Binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName
        Binding.MessageEncoding = WSMessageEncoding.Mtom
        Binding.ReceiveTimeout = New TimeSpan(0, 5, 0)
        Binding.OpenTimeout = New TimeSpan(0, 5, 0)
        Binding.CloseTimeout = New TimeSpan(0, 5, 0)
        Binding.SendTimeout = New TimeSpan(0, 5, 0)
        ' Set the transport security to UsernameOverTransport for Plaintext usernames
        EndPoint = New EndpointAddress("htp://server:1234/webservices/thewebservice")
        'Create the SOAP Client (and pass in the endpoint and the binding)
        etFramework = New MyServiceReference.thewebserviceClient(Binding, EndPoint)
        ''Set the username and password
        etFramework.ClientCredentials.UserName.UserName = "theusername"
        etFramework.ClientCredentials.UserName.Password = "thepassword"
        req = New MyServiceReference.theservicenameRequest(strXMLToSubmit)
        rsp1 = etFramework.MyServiceReference_thewebservice_theservicename(req)
        Debug.WriteLine(rsp1.ToString())