在Visual Basic 2010 Express中使用WSDL [英] Consume a WSDL in Visual Basic 2010 Express

查看:71
本文介绍了在Visual Basic 2010 Express中使用WSDL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好群组。我试图在Visual Basic Express 2010中使用WSDL文件。 我已经将WSDL添加为Web引用,并且可以实例化一个对象来调用SOAP服务。 我还可以实例化响应和请求对象,所有在Visual Studio生成的reference.vb类中都定义了
。 我遇到的问题是由Visual Studio生成的对象构建的实际xml请求不包含任何标头信息(它应该具有用户名和密码),因此SOAP
服务拒绝我的请求和消息"用户名丢失"。 我已经在Visual Studio生成的请求和服务所需的实际请求以及提供给我的WSDL文件下面发布了。 由于我是新手,
我不知道我是否做错了,如果VS解释WSDL错误,或者WSDL文件有问题。 这是来自第三方的常用WSDL文件,因此我发现很难相信它有问题。 
我更改了名称空间和一些元素名称以保持通用。

Hi.  I am trying to consume a WSDL file in Visual Basic Express 2010.  I have added the WSDL as a web reference, and can instantiate an object to make calls to the SOAP service.  I can also instantiate response and request objects, all defined in the Visual Studio generated reference.vb class.  The problem I am having is that the actual xml request built by the Visual Studio generated object does not contain any header information (it is supposed to have a username and password), so the SOAP service rejects my request with the message "Username is missing".  I have posted below the Visual Studio generated request and the actual request that the service needs, as well as the WSDL file that was provided to me.  Since I am new to this, I don't know if I am doing something wrong, if VS is interpreting the WSDL wrong, or if there is a problem with the WSDL file.  This is a commonly used WSDL file from a 3rd party, so I find it hard to believe that it has a problem.  I have changed the namespaces and some element names to remain generic.

非常感谢任何帮助或指示。

Any help or direction is greatly appreciated.

 

 


<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <requestElement1 xmlns="http://test.com/">
            <arg0 xmlns="">
                <Number1>12345</Number1>
                <String1>1122334455</String1>
            </arg0>
        </requestElement1>
    </soap:Body>
</soap:Envelope>

推荐答案

这是WSDL文件:


<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://test.com/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="SOAPService" targetNamespace="http://test.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UTOverTransport">
    <wsp:ExactlyOne>
      <wsp:All>
        <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <wsp:Policy>
            <sp:TransportToken>
              <wsp:Policy>
                <sp:HttpsToken RequireClientCertificate="false" />
              </wsp:Policy>
            </sp:TransportToken>
            <sp:AlgorithmSuite>
              <wsp:Policy>
                <sp:Basic256 />
              </wsp:Policy>
            </sp:AlgorithmSuite>
            <sp:Layout>
              <wsp:Policy>
                <sp:Lax />
              </wsp:Policy>
            </sp:Layout>
            <sp:IncludeTimestamp />
          </wsp:Policy>
        </sp:TransportBinding>
        <sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <wsp:Policy>
            <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient" />
          </wsp:Policy>
        </sp:SignedSupportingTokens>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsdl:types>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://test.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
	  <xs:element name="requestElement1" type="tns:requestElement1" />
      <xs:element name="requestElement1Response" type="tns:requestElement1Response" />
      <xs:complexType name="requestElement1">
        <xs:sequence>
          <xs:element minOccurs="0" name="arg0" type="tns:requestObject1" />
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="requestObject1">
        <xs:sequence>
          <xs:element minOccurs="0" name="Number1" type="xs:int" />
          <xs:element name="String1" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="requestElement1Response">
        <xs:sequence>
          <xs:element minOccurs="0" name="return" type="tns:responseObject1" />
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="responseObject1">
        <xs:sequence>
          <xs:element name="String2" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="requestItems">
        <xs:sequence>
          <xs:element maxOccurs="unbounded" name="item" type="tns:requestItem" />
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="requestItem">
        <xs:sequence>
          <xs:element name="status" type="tns:lineStatus" />
          <xs:element name="element_1" type="xs:string" />
          <xs:element name="elementType" type="tns:elementType" />
          <xs:element name="elementQuantity" type="xs:string" />
           <xs:element minOccurs="0" name="elementGroups" type="tns:elementGroups" />
        </xs:sequence>
        <xs:attribute name="lineNumber" type="xs:int" use="required" />
      </xs:complexType>
      <xs:complexType name="elementGroups">
        <xs:sequence>
          <xs:element maxOccurs="unbounded" name="group" type="tns:group" />
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="group">
        <xs:sequence>
          <xs:element name="elementID" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="requestElement1Response">
    <wsdl:part name="parameters" element="tns:requestElement1Response" />
  </wsdl:message>
  <wsdl:message name="requestElement1">
    <wsdl:part name="parameters" element="tns:requestElement1" />
  </wsdl:message>
  <wsdl:portType xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" wsp:PolicyURIs="#UTOverTransport" name="SOAPService">
    <wsdl:operation name="requestElement1">
      <wsdl:input name="requestElement1" message="tns:requestElement1" />
      <wsdl:output name="requestElement1Response" message="tns:requestElement1Response" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="SOAPServiceSoapBinding" type="tns:SOAPService">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="requestElement1">
      <soap:operation soapAction="" style="document" />
      <wsdl:input name="requestElement1">
        <soap:body parts="parameters" use="literal" />
      </wsdl:input>
      <wsdl:output name="requestElement1Response">
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="SOAPService">
    <wsdl:port name="SOAPServicePort" binding="tns:SOAPServiceSoapBinding">
      <soap:address location="http://a.test.com/service" />
    </wsdl:port>
    <wsdl:port name="SOAPServicePort_UAT" binding="tns:SOAPServiceSoapBinding">
      <soap:address location="http://a2.test.com/service" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>


这篇关于在Visual Basic 2010 Express中使用WSDL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆