小编Ore*_* P.的帖子

xjc/wsimport - 忽略JAXB绑定

当目标wsdl/xsds放在某些特定路径下时,wsimport和xjc命令(两者都作为Java JDK的一部分下载)忽略了提供的jaxb绑定文件.

要重现此行为,可以使用路径C:\ a.该目录包含以下XSD文件:

nm.xsd:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:include schemaLocation="name.xsd"/>
<xs:annotation>
    <xs:documentation xml:lang="en">Annotation</xs:documentation>
</xs:annotation>

<xs:element name="name" type="Name"/>

<xs:complexType name="FName">
<xs:sequence>
    <xs:element name="value" type="xs:string"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="LName">
<xs:sequence>
    <xs:element name="value" type="xs:string"/>
</xs:sequence>
</xs:complexType>

</xs:schema>
Run Code Online (Sandbox Code Playgroud)

name.xsd:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="Name">
        <xs:sequence>
            <xs:element name="FirstName" type="FName"/>
            <xs:element name="LastName" type="LName"/>
            <xs:element name="Date" type="xs:date"/>
        </xs:sequence>
</xs:complexType>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

bindings.xjb:

<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc= "http://java.sun.com/xml/ns/jaxb/xjc">
    <jxb:globalBindings generateElementProperty="false" collectionType="indexed">
        <jxb:javaType name="java.util.Date" xmlType="xs:date" parseMethod="com.company.Converter.parseDate" printMethod="com.company.Converter.printDate"/>
    </jxb:globalBindings>
</jxb:bindings>
Run Code Online (Sandbox Code Playgroud)

从C:\ a使用以下命令来生成JAXB工件:

xjc -b bindings.xjb nm.xsd
Run Code Online (Sandbox Code Playgroud)

绑定被忽略.生成的类仍使用xs:date而不是java.util.Date,并且未生成适配器类.将wsimport与导入XSD的wsdl一起使用时,问题也是可重现的. …

java wsdl jaxb xjc wsimport

9
推荐指数
1
解决办法
1105
查看次数

Windows将数据包转发到c#应用程序

有没有办法在Windows(10)上将tcp数据包转发到我的c#应用程序,让TcpListener/HttpListener处理请求?在linux中,我可以通过设置iptables(iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 7000)来实现.

例如,在我的c#应用程序中,我可以监听特定端口上的传入连接(使用TcpListener或套接字侦听器),比方说7000.我能以某种方式配置窗口以将所有tcp流量转发到127.0.0.1:7000吗?请记住,数据包的目标IP地址与网络中计算机的地址不同(当然,目标硬件地址相同).

我在c#中尝试了使用Pcap .Net的不同方法.我正在捕获数据包并将它们转发到127.0.0.1.但是,似乎我的主机仍然没有捕获数据包(也许它正在将数据包发送到网关,试图在网络中找到具有该IP的主机?).我总是可以在网络中使用我的本地IP地址,但这会导致数据包进入网关,然后再次返回,这是无关紧要的,因为我想要的是我的TcpListener识别传入的连接.我正在使用的代码:

static void processPacket(Packet packet) {
    EthernetLayer ethernetLayer = (EthernetLayer)packet.Ethernet.ExtractLayer();
    IpV4Layer ipLayer = (IpV4Layer)packet.Ethernet.IpV4.ExtractLayer();

    if (ipLayer.Protocol == IpV4Protocol.Tcp) {
        TcpLayer tcpLayer = (TcpLayer)packet.Ethernet.IpV4.Tcp.ExtractLayer();

        if (tcpLayer.DestinationPort == 80) {
           Packet newPacket = BuildTcpPacket(packet, "127.0.0.1"); //copies the packet but changes the ip destination address to 127.0.0.1
                Communicator.SendPacket(newPacket);
                return;
        }
     }
     reroutePacket(packet); //forwards packet to correct destination
 }
Run Code Online (Sandbox Code Playgroud)

c# windows port forward pcap.net

8
推荐指数
1
解决办法
1561
查看次数

通过哈希码获取对象

我不明白为什么没有本机功能来做到这一点.假设我创建了以下类:

public class Student {
     public string Name {get; set;}
     public override int GetHashCode() {
         return(Name.GetHashCode());
     }
}
Run Code Online (Sandbox Code Playgroud)

之后,我创建了一个HashSet包含许多学生的人.现在我想让一个学生HashSet使用他的名字,这也是使用的哈希码,没有枚举.这可能吗?如果是的话,我该如何做到这一点?由于学生的名字被用作哈希码,这应该可以通过O(1)操作实现,对吧?

c# hash hashcode

2
推荐指数
1
解决办法
490
查看次数

标签 统计

c# ×2

forward ×1

hash ×1

hashcode ×1

java ×1

jaxb ×1

pcap.net ×1

port ×1

windows ×1

wsdl ×1

wsimport ×1

xjc ×1