1

好的,所以我正在开发客户端和服务应用程序。Web Service 是 JAX-WS,客户端是 C#。

这是请求信封:

<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
  <s:Header>
    <a:Action s:mustUnderstand="1">http://service.client.controlbox.pupin.com/ClientService/getProgramRequest</a:Action>
    <a:MessageID>urn:uuid:0611ad42-9d6a-4231-b5dc-b184ff8d767b</a:MessageID>
    <a:ReplyTo>
      <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
    <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo/TFchxPpdRKkxTMgu4zqLoAAAAA+TipUcLz4UqIiUeu7LDdk9hWXiZtaslHl/445+teciMACQAA</VsDebuggerCausalityData>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <getProgram xmlns="http://service.client.controlbox.pupin.com/">
      <macAddress xmlns="">234</macAddress>
    </getProgram>
  </s:Body>
</s:Envelope>

这是响应信封:

<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <S:Header>
    <Action xmlns="http://www.w3.org/2005/08/addressing" xmlns:S="http://www.w3.org/2003/05/soap-envelope" S:mustUnderstand="true">http://service.client.controlbox.pupin.com/ClientService/getPrograResponse</Action>
    <MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:c6aa9ecc-24d3-439a-b057-c03aca37eb1f</MessageID>
    <RelatesTo xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:0611ad42-9d6a-4231-b5dc-b184ff8d767b</RelatesTo>
    <To xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</To>
    <wsse:Security S:mustUnderstand="true">
      <wsu:Timestamp xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:ns13="http://schemas.xmlsoap.org/soap/envelope/" wsu:Id="_1">
        <wsu:Created>2013-05-07T10:25:28Z</wsu:Created>
        <wsu:Expires>2013-05-07T10:30:28Z</wsu:Expires>
      </wsu:Timestamp>
    </wsse:Security>
  </S:Header>
  <S:Body>
    <ns2:getProgramResponse xmlns:ns2="http://service.client.controlbox.pupin.com/">
      <return>
        <name>asd</name>
        <logo>
          <alpha>100</alpha>
          <media>
            <filePath>Tulips_2.jpg</filePath>
          </media>
          <offset>0;0;0;0</offset>
          <position>1</position>
        </logo>
        <programPlaylistList>
          <endTime>
            <nanos>0</nanos>
          </endTime>
          <endTimeCalculated>true</endTimeCalculated>
          <logoShown>false</logoShown>
          <playlist>
            <name>plejlista</name>
            <playlistMediaList>
              <duration>5</duration>
              <media>
                <filePath>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.jpg</filePath>
              </media>
            </playlistMediaList>
            <playlistMediaList>
              <duration>5</duration>
              <media>
                <filePath>Koala.jpg</filePath>
              </media>
            </playlistMediaList>
            <playlistMediaList>
              <duration>15</duration>
              <media>
                <filePath>Hydrangeas.jpg</filePath>
              </media>
            </playlistMediaList>
            <playlistMediaList>
              <duration>10</duration>
              <media>
                <filePath>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.jpg</filePath>
              </media>
            </playlistMediaList>
            <playlistMediaList>
              <duration>5</duration>
              <media>
                <filePath>Lighthouse.jpg</filePath>
              </media>
            </playlistMediaList>
          </playlist>
          <repeatedDaily>false</repeatedDaily>
          <startTime>
            <nanos>0</nanos>
          </startTime>
          <tickerDisabled>false</tickerDisabled>
          <weatherAfter>0</weatherAfter>
        </programPlaylistList>
        <updated>false</updated>
        <weather>
          <name>prognoza</name>
          <background>
            <name>
            </name>
            <filePath>background.png</filePath>
          </background>
          <duration>20</duration>
          <twoSlideWeather>false</twoSlideWeather>
        </weather>
      </return>
    </ns2:getProgramResponse>
  </S:Body>
</S:Envelope>

如您所见,所有参数都在那里,但对象字段未初始化。

这是我的客户代码:

HttpsTransportBindingElement transport = new HttpsTransportBindingElement();

TransportSecurityBindingElement b_element = new TransportSecurityBindingElement();
b_element.DefaultAlgorithmSuite = new Basic128SecurityAlgorithmSuite();
b_element.IncludeTimestamp = true;
b_element.KeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy;
b_element.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11;
b_element.SecurityHeaderLayout = SecurityHeaderLayout.Lax;

CustomBinding customBinding = new CustomBinding();
customBinding.Name = "secureBinding";
customBinding.Elements.Add(b_element);
customBinding.Elements.Add(transport);

ServiceRef.ClientServiceClient proxy = new ServiceRef.ClientServiceClient();
proxy.Endpoint.Binding = customBinding;
proxy.Endpoint.EndpointBehaviors.Add(new MessageInspectionBehavior());

Console.WriteLine(proxy.getProgram("234").logo==null);

Console.Read();

你可以想象proxy.getProgram("234").logo==nulltrue

我在互联网上阅读了类似的问题,每个人都说它的名称空间不匹配问题,但我无法发现我的问题,如果有人能帮我解决这个问题,我将不胜感激。

请帮忙,我真的被困在这里了。谢谢

编辑

好的,我用java制作了服务客户端,同样的事情正在发生。所以看来我的 Web 服务有问题。

有人帮助,我需要快速帮助,甚至没有人试图帮助...... :(

4

0 回答 0