从Java Web Service获得VB.NET客户端的响应

如何解决从Java Web Service获得VB.NET客户端的响应

| 这是情况。我是Java开发人员。我们公司的另一位开发人员为我们的客户编写了一个Web服务。他们用Java编写了服务。他们还编写了一个演示来创建客户端以使用Java来使用Web服务,并且演示工作正常。我的任务是在VB.NET中创建一个Web服务客户端以执行相同的操作。进行得并不顺利。问题在于Web服务要求您在SOAP标头中发送用户名和密码,而我不知道如何在Vb.NET中做到这一点。我看了以下几页: http://msdn.microsoft.com/zh-CN/library/system.servicemodel.httptransportsecurity.aspx http://msdn.microsoft.com/zh-CN/library/system.servicemodel.basichttpsecurity.aspx http://msdn.microsoft.com/en-us/library/ms553830.aspx 我不能让他们任何一个工作。我从Web服务中始终获得“带有用户名和加密密码的肥皂标头丢失”。我已经尝试了上一个问题中给出的所有建议: 需要在VB.NET Web服务客户端中的SOAP标头中添加用户名和密码 我仍然遇到相同的错误。 这是我编写的代码。
Imports System.Net
Imports System.ServiceModel

Public Class RandomQuoteForm

    Private Sub GetQuoteButton_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles GetQuoteButton.Click
        Dim imageService As AverittWebServices.SendWebImageClient = New AverittWebServices.SendWebImageClient(\"SendWebImagePort\")
        imageService.ClientCredentials.UserName.UserName = \"apriltest11\"
        imageService.ClientCredentials.UserName.Password = \"ew6ttRob1LY+Ik9E5oKlbA==\"
        Dim imageResult As String

        imageResult = imageService.getAvailableImages(\"\")
        DisplayLabel.Text = imageResult
    End Sub
End Class
这是WSDL:
<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI\'s version is JAX-WS RI 2.1.6 in JDK 6. -->
<definitions targetNamespace=\"https://webservices.averittexpress.com/SendWebImageService\" name=\"SendWebImageService\" xmlns=\"http://schemas.xmlsoap.org/wsdl/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"https://webservices.averittexpress.com/SendWebImageService\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\">
  <types>
    <xsd:schema>
      <xsd:import namespace=\"https://webservices.averittexpress.com/SendWebImageService\" schemaLocation=\"SendWebImageService_schema1.xsd\"/>
    </xsd:schema>
  </types>
  <message name=\"getDocument\">
    <part name=\"parameters\" element=\"tns:getDocument\"/>
  </message>
  <message name=\"getDocumentResponse\">
    <part name=\"parameters\" element=\"tns:getDocumentResponse\"/>
  </message>
  <message name=\"getAvailableImages\">
    <part name=\"parameters\" element=\"tns:getAvailableImages\"/>
  </message>
  <message name=\"getAvailableImagesResponse\">
    <part name=\"parameters\" element=\"tns:getAvailableImagesResponse\"/>
  </message>
  <portType name=\"SendWebImage\">
    <operation name=\"getDocument\">
      <input message=\"tns:getDocument\"/>
      <output message=\"tns:getDocumentResponse\"/>
    </operation>
    <operation name=\"getAvailableImages\">
      <input message=\"tns:getAvailableImages\"/>
      <output message=\"tns:getAvailableImagesResponse\"/>
    </operation>
  </portType>
  <binding name=\"SendWebImagePortBinding\" type=\"tns:SendWebImage\">
    <soap:binding transport=\"http://schemas.xmlsoap.org/soap/http\" style=\"document\"/>
    <operation name=\"getDocument\">
      <soap:operation soapAction=\"\"/>
      <input>
        <soap:body use=\"literal\"/>
      </input>
      <output>
        <soap:body use=\"literal\"/>
      </output>
    </operation>
    <operation name=\"getAvailableImages\">
      <soap:operation soapAction=\"\"/>
      <input>
        <soap:body use=\"literal\"/>
      </input>
      <output>
        <soap:body use=\"literal\"/>
      </output>
    </operation>
  </binding>
  <service name=\"SendWebImageService\">
    <port name=\"SendWebImagePort\" binding=\"tns:SendWebImagePortBinding\">
      <soap:address location=\"https://webservices.averittexpress.com/SendWebImageService\"/>
    </port>
  </service>
</definitions>
这是架构:
<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<xs:schema version=\"1.0\" targetNamespace=\"https://webservices.averittexpress.com/SendWebImageService\" xmlns:tns=\"https://webservices.averittexpress.com/SendWebImageService\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">

  <xs:element name=\"getAvailableImages\" type=\"tns:getAvailableImages\"/>

  <xs:element name=\"getAvailableImagesResponse\" type=\"tns:getAvailableImagesResponse\"/>

  <xs:element name=\"getDocument\" type=\"tns:getDocument\"/>

  <xs:element name=\"getDocumentResponse\" type=\"tns:getDocumentResponse\"/>

  <xs:complexType name=\"getDocument\">
    <xs:sequence>
      <xs:element name=\"arg0\" type=\"xs:string\" minOccurs=\"0\"/>
      <xs:element name=\"arg1\" type=\"xs:string\" minOccurs=\"0\"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name=\"getDocumentResponse\">
    <xs:sequence>
      <xs:element name=\"return\" type=\"xs:base64Binary\" nillable=\"true\" minOccurs=\"0\"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name=\"getAvailableImages\">
    <xs:sequence>
      <xs:element name=\"arg0\" type=\"xs:string\" minOccurs=\"0\"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name=\"getAvailableImagesResponse\">
    <xs:sequence>
      <xs:element name=\"return\" type=\"xs:string\" minOccurs=\"0\"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>
我花了整整3天的时间来尝试使它生效。我毫不怀疑,VB.NET开发人员可以在匆忙之后将其淘汰。我不是那个开发人员,说实话,我还有其他我想做的事情。我已经到了愿意尝试一些不同之处的地步。所以,这是交易。对于第一个使用代码发布此问题的答案的开发人员,我可以在笔记本电脑上工作(Visual Basic Express Edition 2010),并获得使笔记本电脑正常工作所需的任何解释,我将向他们选择的慈善机构捐款100美元。这不是一个改变世界的数额,但我知道的大多数慈善机构都会对此表示赞赏。 用户名必须为\“ apriltest11 \”。 加密的密码必须为\“ ew6ttRob1LY + Ik9E5oKlbA == \”。 可以传递给getAvailableImages方法的有效参数是:0419151598和1022600388 WSDL是公开可用的,并且用户名/密码组合仅用于测试,因此不要觉得我在这里放弃了王国的密钥。我很想得到这个答案。我不仅可以返回到我的普通Java项目,而且在这一点上,我实际上想看看如何完成此工作。 用于设置用户名和密码的Java代码:
URL wsdlLocation = new URL(\"C:/ .../WEB-INF/wsdl/EncryptedPasswordService.wsdl\");
QName qName =new QName(\"https://webservices.averittexpress.com/EncryptedPasswordService\");

EncryptedPasswordService service = new EncryptedPasswordService(wsdlLocation,qName);
EncryptedPassword port = service.getEncryptedPasswordPort();
String encryptedPwd = port.getEncryptedPwd(\"username\",\"password\");
谢谢。     

解决方法

您的Java Web服务是否正确发布了元数据。如果是这样,我相信您可以右键单击Visual Studio解决方案资源管理器并添加Web参考,这将为您创建代理。 仅当您使用Visual Studio时,此方法才能解决。我不知道Java开发人员是否喜欢ot。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-